Sound

Sound : Instance

Overview

Sound is an object that plays audio.

When a Sound is parented to a BasePart or Attachment, it plays at that location and its volume changes with distance from the listener. Otherwise, it plays at the same volume throughout the place.

The playback range of a Sound is determined by the combination of PlaybackRegionsEnabled, StartTimePosition, PlaybackRegion, LoopRegion, and Looped. For detailed playback range control, see the Sound manual.

Properties

IsLoaded

bool

Indicates whether the sound has been loaded on the server and is ready to play. Use it together with the Loaded event to check if the sound is loaded before playing.

Code Samples

local Workspace = game:GetService("Workspace")
local Sound = Workspace.Sound

if Sound.IsLoaded then
    Sound:Play()
else
    Sound.Loaded:Wait()
    Sound:Play()
end

IsPaused

bool

Returns true when the sound is not playing. It is true when the sound has been paused or stopped via Pause() or Stop(), or has never been played.

This is a read-only property; use the Pause() or Stop() method to control playback.

Code Samples

IsPlaying

bool

Returns true when the sound is currently playing. Unlike the Playing property, this is read-only; use the Play() method to control playback.

Code Samples

Looped

bool

Sets whether the sound plays in a loop. When set to true, the sound restarts from the beginning (or loop start) after it finishes.

You can track the number of loops with the DidLoop event.

Code Samples

LoopRegion

NumberRange

A range in seconds that defines the desired loop start and end time within the PlaybackRegion.

To use this property, PlaybackRegionsEnabled must be true and Looped must be true. This property applies only during looped playback; on the first play, PlaybackRegion is used.

LoopRegion is applied as follows:

  • First play (DidLoop = 0): PlaybackRegion is used; LoopRegion is ignored.

  • Loop play (DidLoop β‰₯ 1): The narrower of LoopRegion and PlaybackRegion is used.

    • LoopRegion.Min > PlaybackRegion.Min: Start at LoopRegion.Min

    • LoopRegion.Min ≀ PlaybackRegion.Min: Start at PlaybackRegion.Min

    • LoopRegion.Max < PlaybackRegion.Max: End at LoopRegion.Max

    • LoopRegion.Max β‰₯ PlaybackRegion.Max: End at PlaybackRegion.Max

  • LoopRegion.Min = LoopRegion.Max: This property is disabled and PlaybackRegion is used for the loop as well.

Code Samples

PlaybackLoudness

number

Represents the current loudness (amplitude) of the playing sound in the range 0–1000. Useful for audio visualization or sound-reactive effects.

This property reflects the volume the client actually hears, so it always returns 0 when read on the server.

Code Samples

PlaybackRegion

NumberRange

A range in seconds that defines the desired start and end time within TimeLength.

PlaybackRegionsEnabled must be set to true to use this property.

Behavior:

  • PlaybackRegion.Min > 0: Playback starts at PlaybackRegion.Min.

  • PlaybackRegion.Min ≀ 0: Playback starts at 0 (negative values are clamped to 0).

  • PlaybackRegion.Max < TimeLength: Playback ends exactly at that time.

  • PlaybackRegion.Max β‰₯ TimeLength: Playback ends at TimeLength.

  • PlaybackRegion.Min = PlaybackRegion.Max: This property is disabled (playback from 0 to TimeLength).

Code Samples

PlaybackRegionsEnabled

bool

Enables PlaybackRegion and LoopRegion so you can play only a specific part of the sound or define a loop segment. When PlaybackRegionsEnabled is on, StartTimePosition is ignored.

Code Samples

PlaybackSpeed

number

Sets the playback speed of the sound. 1.0 is normal speed; higher values play faster and lower values play slower. Changing playback speed also changes the pitch.

Code Samples

Playing

bool

Indicates the playback state of the sound and can be set directly.

Behavior:

  • Playing = false: Pauses the sound (TimePosition is preserved).

  • Playing = true: Resumes playback from the current TimePosition.

  • Difference from Play(): Play() starts from StartTimePosition (or PlaybackRegion.Min).

Code Samples

PlayOnRemove

bool

When set to true, the sound plays when the Sound instance is removed. If the sound is not playing when removed, it starts from the beginning; if it is playing when removed, it continues from the current position.

Useful for playing sounds when objects disappear, such as explosion or destruction effects.

The sound plays in these cases:

  • sound:Destroy()

  • sound.Parent = nil

  • sound.Parent.Parent = nil

Code Samples

RollOffMaxDistance

number

Sets the maximum distance in studs at which a 3D sound (parented to a BasePart or Attachment) can be heard. Beyond this distance, the sound is inaudible.

How the sound attenuates depends on RollOffMode.

Code Samples

RollOffMinDistance

number

Sets the minimum distance in studs at which a 3D sound (parented to a BasePart or Attachment) is heard at full volume. Beyond this distance, the sound attenuates according to RollOffMode.

Code Samples

RollOffMode

Enum.RollOffMode

Sets how the volume of a 3D sound (parented to a BasePart or Attachment) attenuates with distance. It determines how the sound fades between RollOffMinDistance and RollOffMaxDistance.

Code Samples

SoundGroup

SoundGroup

Sets the SoundGroup this sound belongs to. All sounds in a SoundGroup are affected by the group’s Volume setting, so you can control their volume together.

Code Samples

SoundId

string

The asset ID of the sound file to play. Specify the sound asset using the ovdrassetid:// format.

Code Samples

StartTimePosition

number

Sets the position in seconds from which to start when playing with the Play() method. This property only works when PlaybackRegionsEnabled = false.

Notable behavior:

  • Negative values are clamped to 0.

  • When Looped = true: Applied only on the first play; loops start from 0.

  • Resume() or Playing = true resumes from the current TimePosition, not StartTimePosition.

Code Samples

TimeLength

number

The total length of the sound in seconds. Returns 0 if the sound is not loaded.

Use with PlaybackSpeed to adjust speed so the sound plays for a desired duration.

Code Samples

TimePosition

number

The current playback position of the sound in seconds. Changing this value immediately seeks the playback position while the sound is playing.

While the sound is playing, TimePosition increases at a rate of PlaybackSpeed per second and stops when it reaches TimeLength unless Looped is true.

Code Samples

Volume

number

Sets the volume of the sound. Value between 0 (mute) and 10 (max); default is 0.5.

If the sound is in a SoundGroup, it is also affected by the group’s Volume setting.

Code Samples

Methods

Pause

Pauses the sound. TimePosition is preserved, so you can resume from the same position with Resume().

Parameters

Return

void

Code Samples

Play

Starts playing the sound. The start position depends on the PlaybackRegionsEnabled setting.

Start position:

  • PlaybackRegionsEnabled = false: Starts from StartTimePosition

  • PlaybackRegionsEnabled = true: Starts from PlaybackRegion.Min

Calling Play() again while playing seeks back to the start position.

Parameters

Return

void

Code Samples

Resume

Resumes a paused sound from the current TimePosition. Used together with Pause().

Parameters

Return

void

Code Samples

Stop

Stops the sound and resets TimePosition to 0 while keeping other properties unchanged.

So after Stop(), calling Play() will start from StartTimePosition.

Parameters

Return

void

Code Samples

Events

DidLoop

Fires each time the sound loops. Calling Stop() resets the loop counter to 0.

Parameters

string SoundId

SoundId of the sound that looped

number numOfTimesLooped

Number of times the sound has looped

Code Samples

Ended

Fires when the sound has played to the end and stopped.

It does not fire in these cases:

  • When Looped = true

  • When stopped with Stop() before the end (use the Stopped event instead)

Parameters

string SoundId

SoundId of the sound that finished playing

Code Samples

Loaded

Fires when the sound is loaded. It does not fire if the sound is already loaded, so it is best to check IsLoaded first.

Parameters

string SoundId

SoundId of the loaded sound

Code Samples

Paused

Fires when the sound is paused via the Pause() method.

Parameters

string SoundId

SoundId of the paused sound

Code Samples

Played

Fires each time the sound starts playing via the Play() method.

Does not fire when playback starts due to PlayOnRemove = true.

Parameters

string SoundId

SoundId of the sound that played

Code Samples

Resumed

Fires when the sound is resumed via the Resume() method.

Parameters

string SoundId

SoundId of the resumed sound

Code Samples

Stopped

Fires when:

  • The sound is stopped with the Stop() method

  • SoundId is changed while the sound is playing

It does not fire when the sound is destroyed with Destroy().

Parameters

string SoundId

SoundId of the stopped sound

Code Samples

Last updated