Sound
A Sound is an object that emits sound. Sounds can be placed within a BasePart or Attachment to emit a sound from a particular position within a place or world, or it can be attached elsewhere to play the sound at a constant volume throughout the entire place.
Memory category | Internal |
---|
Member index 51
Description
A Sound is an object that emits sound.
2D and 3D Sound
A sound placed in a BasePart or an Attachment will emit its sound from that part's BasePart.Position or the attachment's Attachment.WorldPosition. A sound exhibits the Doppler effect, meaning its frequency and pitch varies with the relative motion of whatever attachment or part it is attached to. The volume of the sound will be determined by the distance between the client's sound listener (by default the Camera position) and the position of the sound's parent. For more information on this see Sound.RollOffMode.
A sound is considered "global" if it is not parented to a BasePart or an Attachment. In this case, the sound will play at the same volume throughout the entire place.
History 203
- 648 Change CanSave of from true to false
- 648 Change Tags of RollOffMinDistance from [NotReplicated] to []
- 648 Change CanSave of RollOffMinDistance from false to true
- 648 Change CanLoad of RollOffMinDistance from false to true
- 648 Change CanLoad of RollOffMaxDistance from false to true
- 648 Change Tags of RollOffMaxDistance from [NotReplicated] to []
- 648 Change CanSave of RollOffMaxDistance from false to true
- 648 Change CanSave of EmitterSize from true to false
- 645 Change ValueType of SoundId from Content to ContentId
- 601 Change PreferredDescriptor of from to RollOffMinDistance
- 601 Change Tags of from [Hidden, NotReplicated, NotScriptable] to [Hidden, NotReplicated, NotScriptable, Deprecated]
- 601 Change Tags of from [Hidden, NotReplicated, NotScriptable] to [Hidden, NotReplicated, NotScriptable, Deprecated]
- 601 Change PreferredDescriptor of from to RollOffMaxDistance
- 601 Change Tags of MinDistance from [] to [Deprecated]
- 601 Change PreferredDescriptor of MinDistance from to RollOffMinDistance
- 601 Change Tags of MaxDistance from [] to [Deprecated]
- 601 Change PreferredDescriptor of MaxDistance from to RollOffMaxDistance
- 601 Change Tags of EmitterSize from [] to [Deprecated]
- 601 Change PreferredDescriptor of EmitterSize from to RollOffMinDistance
- 599 Change Tags of MinDistance from [Deprecated] to []
- 599 Change PreferredDescriptor of MinDistance from RollOffMinDistance to
- 599 Change Tags of MaxDistance from [Deprecated] to []
- 599 Change PreferredDescriptor of MaxDistance from RollOffMaxDistance to
- 599 Change Tags of EmitterSize from [Deprecated] to []
- 599 Change PreferredDescriptor of EmitterSize from RollOffMinDistance to
- 582 Change Tags of PlaybackRegionsEnabled from [NotBrowsable] to []
- 573 Change ReturnType of stop from void to null
- 573 Change ReturnType of play from void to null
- 573 Change ReturnType of pause from void to null
- 573 Change ReturnType of Stop from void to null
- 573 Change ReturnType of Resume from void to null
- 573 Change ReturnType of Play from void to null
- 573 Change ReturnType of Pause from void to null
- 562 Add
- 562 Add
- 553 Add
- 553 Add
- 553 Add
- 553 Add
- 553 Add
- 553 Change PreferredDescriptor of stop from to Stop
- 553 Change PreferredDescriptor of play from to Play
- 553 Change PreferredDescriptor of pause from to Pause
- 553 Add
- 553 Add
- 553 Change Default of isPlaying from to false
- 553 Change PreferredDescriptor of isPlaying from to IsPlaying
- 553 Change Category of Volume from Data to Playback
- 553 Change Default of Volume from to 0.5
- 553 Change Default of from to Default
- 553 Add
- 553 Change Category of TimePosition from Data to Playback
- 553 Change Default of TimePosition from to 0
- 553 Change Category of TimeLength from Data to Asset
- 553 Change Default of TimeLength from to 0
- 553 Change Category of SoundId from Data to Asset
- 553 Change Category of SoundGroup from Data to Routing
- 553 Change Default of SoundGroup from to
- 553 Change Category of RollOffMode from Data to Emitter
- 553 Change Default of RollOffMode from to Inverse
- 553 Change Category of RollOffMinDistance from Data to Emitter
- 553 Change Default of RollOffMinDistance from to 10
- 553 Change Default of RollOffMaxDistance from to 10000
- 553 Change Category of RollOffMaxDistance from Data to Emitter
- 553 Add
- 553 Change Category of Playing from Data to Playback
- 553 Change Default of Playing from to false
- 553 Change Category of PlaybackSpeed from Data to Playback
- 553 Change Default of PlaybackSpeed from to 1
- 553 Change Default of PlaybackRegionsEnabled from to false
- 553 Change Default of PlaybackRegion from to NumberRange(0 60000 )
- 553 Change Default of PlaybackLoudness from to 0
- 553 Change Category of PlaybackLoudness from Data to Playback
- 553 Change Default of PlayOnRemove from to false
- 553 Change PreferredDescriptor of Pitch from to PlaybackSpeed
- 553 Change Default of Pitch from to 1
- 553 Change PreferredDescriptor of MinDistance from to RollOffMinDistance
- 553 Change Default of MinDistance from to 10
- 553 Change PreferredDescriptor of MaxDistance from to RollOffMaxDistance
- 553 Change Default of MaxDistance from to 10000
- 553 Change Category of Looped from Data to Playback
- 553 Change Default of Looped from to false
- 553 Change Default of LoopRegion from to NumberRange(0 60000 )
- 553 Change Tags of from [ReadOnly, NotReplicated] to [Hidden, ReadOnly, NotReplicated]
- 553 Change Default of from to false
- 553 Change Category of from Data to Playback
- 553 Change Category of from Data to Playback
- 553 Change Tags of from [ReadOnly, NotReplicated] to [Hidden, ReadOnly, NotReplicated]
- 553 Change Default of from to true
- 553 Change Category of IsLoaded from Data to Asset
- 553 Change Default of IsLoaded from to false
- 553 Change PreferredDescriptor of EmitterSize from to RollOffMinDistance
- 553 Change Default of EmitterSize from to 10
- 553 Change Category of ChannelCount from Data to Asset
- 553 Change Default of ChannelCount from to 0
- 549 Add PlaybackRegionsEnabled
- 549 Add PlaybackRegion
- 549 Add LoopRegion
- 516 Add
- 491 Add ChannelCount
- 486 Change ThreadSafety of isPlaying from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Volume from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TimePosition from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TimeLength from ReadOnly to ReadSafe
- 486 Change ThreadSafety of SoundId from ReadOnly to ReadSafe
- 486 Change ThreadSafety of SoundGroup from ReadOnly to ReadSafe
- 486 Change ThreadSafety of RollOffMode from ReadOnly to ReadSafe
- 486 Change ThreadSafety of RollOffMinDistance from ReadOnly to ReadSafe
- 486 Change ThreadSafety of RollOffMaxDistance from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Playing from ReadOnly to ReadSafe
- 486 Change ThreadSafety of PlaybackSpeed from ReadOnly to ReadSafe
- 486 Change ThreadSafety of PlaybackLoudness from ReadOnly to ReadSafe
- 486 Change ThreadSafety of PlayOnRemove from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Pitch from ReadOnly to ReadSafe
- 486 Change ThreadSafety of MinDistance from ReadOnly to ReadSafe
- 486 Change ThreadSafety of MaxDistance from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Looped from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of IsLoaded from ReadOnly to ReadSafe
- 486 Change ThreadSafety of EmitterSize from ReadOnly to ReadSafe
- 462 Change ThreadSafety of Stopped from to Unsafe
- 462 Change ThreadSafety of Resumed from to Unsafe
- 462 Change ThreadSafety of Played from to Unsafe
- 462 Change ThreadSafety of Paused from to Unsafe
- 462 Change ThreadSafety of Loaded from to Unsafe
- 462 Change ThreadSafety of Ended from to Unsafe
- 462 Change ThreadSafety of DidLoop from to Unsafe
- 462 Change ThreadSafety of stop from to Unsafe
- 462 Change ThreadSafety of play from to Unsafe
- 462 Change ThreadSafety of pause from to Unsafe
- 462 Change ThreadSafety of Stop from to Unsafe
- 462 Change ThreadSafety of Resume from to Unsafe
- 462 Change ThreadSafety of Play from to Unsafe
- 462 Change ThreadSafety of Pause from to Unsafe
- 462 Change ThreadSafety of isPlaying from to ReadOnly
- 462 Change ThreadSafety of Volume from to ReadOnly
- 462 Change ThreadSafety of TimePosition from to ReadOnly
- 462 Change ThreadSafety of TimeLength from to ReadOnly
- 462 Change ThreadSafety of SoundId from to ReadOnly
- 462 Change ThreadSafety of SoundGroup from to ReadOnly
- 462 Change ThreadSafety of RollOffMode from to ReadOnly
- 462 Change ThreadSafety of RollOffMinDistance from to ReadOnly
- 462 Change ThreadSafety of RollOffMaxDistance from to ReadOnly
- 462 Change ThreadSafety of Playing from to ReadOnly
- 462 Change ThreadSafety of PlaybackSpeed from to ReadOnly
- 462 Change ThreadSafety of PlaybackLoudness from to ReadOnly
- 462 Change ThreadSafety of PlayOnRemove from to ReadOnly
- 462 Change ThreadSafety of Pitch from to ReadOnly
- 462 Change ThreadSafety of MinDistance from to ReadOnly
- 462 Change ThreadSafety of MaxDistance from to ReadOnly
- 462 Change ThreadSafety of Looped from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of IsLoaded from to ReadOnly
- 462 Change ThreadSafety of EmitterSize from to ReadOnly
- 456 Add RollOffMinDistance
- 456 Add RollOffMaxDistance
- 456 Change Tags of MaxDistance from [] to [Deprecated]
- 456 Change Tags of EmitterSize from [] to [Deprecated]
- 417 Change Tags of TimePosition from [] to [NotReplicated]
- 417 Change Tags of Playing from [] to [NotReplicated]
- 389 Change Tags of PlaybackSpeed from [] to [NotReplicated]
- 329 Change ValueType of SoundGroup from Object to SoundGroup
- 266 Change Tags of RollOffMode from [Hidden] to []
- 264 Add SoundGroup
- 264 Add PlaybackLoudness
- 262 Add PlaybackSpeed
- 262 Change Tags of Pitch from [] to [Deprecated]
- 262 Change Tags of MinDistance from [] to [Deprecated]
- 262 Add EmitterSize
- 249 Add Resumed
- 249 Add Loaded
- 249 Add RollOffMode
- 249 Add Playing
- 249 Add IsLoaded
- 220 Add MinDistance
- 220 Add MaxDistance
- 204 Add Ended
- 182 Add Resume
- 179 Add Stopped
- 179 Add Played
- 179 Add Paused
- 179 Add DidLoop
- 178 Change ValueType of TimePosition from int to double
- 178 Change ValueType of TimeLength from int to double
- 176 Add TimePosition
- 176 Add TimeLength
- 50 Add pause
- 50 Add isPlaying
- 49 Add stop
- 47 Add play
- 47 Add Stop
- 47 Add Play
- 47 Add Pause
- 47 Add Volume
- 47 Add SoundId
- 47 Add PlayOnRemove
- 47 Add Pitch
- 47 Add Looped
- 47 Add
- 47 Add
- 47 Add Sound
Members 51
ChannelCount
Type | Default | |
---|---|---|
int | 0 |
Security | RobloxScriptSecurity |
---|---|
Thread safety | ReadSafe |
Category | Asset |
Loaded/Saved | false |
History 3
- 553 Change Category of ChannelCount from Data to Asset
- 553 Change Default of ChannelCount from to 0
- 491 Add ChannelCount
DidLoop
Parameters (2) | |
---|---|
soundId | string |
numOfTimesLooped | int |
Event that fires whenever the Sound loops. Returns soundId and numOfTimesLooped, giving the contentID of the sound and the number of times looped respectively.
When the Sound is stopped the looped counter resets meaning the next DidLoop event will return 1 for numOfTimesLooped.
Thread safety | Unsafe |
---|
EmitterSize
Type | Default | |
---|---|---|
float | 10 |
The minimum distance, in studs, at which a 3D Sound (direct child of a BasePart or Attachment) will begin to attenuate (decrease in volume).
Sounds parented to a BasePart or Attachment that are descendants of the Workspace are considered 3D sounds and their volume while playing is dependent on the distance between the client's sound listener (Camera position by default) and the Sound's parent. Two properties influence this behavior EmitterSize and Sound.RollOffMode.
The way the Sound attenuates (fades out) after the distance between the listener and the sound exceeds the EmitterSize is determined by RollOffMode.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true/false |
History 11
- 648 Change CanSave of EmitterSize from true to false
- 601 Change Tags of EmitterSize from [] to [Deprecated]
- 601 Change PreferredDescriptor of EmitterSize from to RollOffMinDistance
- 599 Change Tags of EmitterSize from [Deprecated] to []
- 599 Change PreferredDescriptor of EmitterSize from RollOffMinDistance to
- 553 Change PreferredDescriptor of EmitterSize from to RollOffMinDistance
- 553 Change Default of EmitterSize from to 10
- 486 Change ThreadSafety of EmitterSize from ReadOnly to ReadSafe
- 462 Change ThreadSafety of EmitterSize from to ReadOnly
- 456 Change Tags of EmitterSize from [] to [Deprecated]
- 262 Add EmitterSize
Ended
Parameters (1) | |
---|---|
soundId | string |
Fires when the Sound has completed playback and stopped. Note this event will not fire for sounds with Sound.Looped set to true as they continue playing upon reaching their end.
This event is often used to destroy a sound when it has completed playback.
sound:Play()
sound.Ended:Wait()
sound:Destroy()
This event only fires if the sound has reached its end. This means it will also not fire when the sound is stopped before playback has completed, for this use Sound.Stopped.
Thread safety | Unsafe |
---|
IsLoaded
Type | Default | |
---|---|---|
bool | false |
This property will be true when the Sound has loaded from Roblox servers and is ready to play.
In Roblox, audio files are not stored in games themselves but hosted on the Roblox servers and referenced by the Sound.SoundId property. This means that they need to be downloaded to a client's device before they can be played. This can take a while depending on the user's internet connection, the length of the sound and the number of other objects that need to be loaded.
Developers can use the Sound.IsLoaded property and the Sound.Loaded event if they wish to verify a sound has loaded before playing it.
Thread safety | ReadSafe |
---|---|
Category | Asset |
Loaded/Saved | false |
Loaded
Parameters (1) | |
---|---|
soundId | string |
The Sound.Loaded event fires when the Sound is loaded.
Note this event will only fire at the time the sound is loaded. This means if it is listened for when the sound is already loaded it will not return. Therefore it is recommended to check Sound.IsLoaded prior to connecting to this event.
Thread safety | Unsafe |
---|
LoopRegion
Type | Default | |
---|---|---|
NumberRange | 0 60000 |
A range denoting a desired loop-start and loop-end within the Sound's Sound.PlaybackRegion in seconds.
If
LoopRegion.Min
> PlaybackRegion.Min, the loop starts from theLoopRegion.Min
.If
LoopRegion.Min
< PlaybackRegion.Min, the loop starts from the PlaybackRegion.Min.If
LoopRegion.Max
> PlaybackRegion.Max, the loop starts at PlaybackRegion.Max.If
LoopRegion.Max
< PlaybackRegion.Max, the loop starts at exactly that time.If
LoopRegion.Min
==LoopRegion.Max
, the Sound uses the Sound.PlaybackRegion property instead.
Thread safety | ReadSafe |
---|---|
Category | Regions |
Loaded/Saved | true |
History 2
- 553 Change Default of LoopRegion from to NumberRange(0 60000 )
- 549 Add LoopRegion
Looped
Type | Default | |
---|---|---|
bool | false |
This sets whether or not the Sound repeats once it has finished when it is playing.
Looped sounds are suitable for a range of applications including music and background ambient sounds. The Sound.DidLoop event can be used to track the number of times as sound has looped.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
MaxDistance
Type | Default | |
---|---|---|
float | 10000 |
The maximum distance, in studs, a client's listener can be from the Sound origin and still hear it. Only applies to Sounds parented to a Part or Attachment (3D sounds).
How MaxDistance impacts the attenuation of a sound (manner in which it fades out) is dependent on the Sound.RollOffMode property. When RollOffMode is set to use an inverse type distance model (Inverse or InverseTapered) the MaxDistance will not effect the attenuation of the sound. This means that low values for MaxDistance will cause the sound to abruptly cut off when the listener reaches the MaxDistance. In most cases this is not desirable and developers are advised not to use low MaxDistance values.
When RollOffMode is set to a linear type distance model (Linear or LinearSquared) the sound will attenuate between Sound.EmitterSize and MaxDistance (with playback volume reaching zero at MaxDistance). This is less realistic, but in some cases allows attenuation to be handled in a more intuitive way.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
History 10
- 601 Change Tags of MaxDistance from [] to [Deprecated]
- 601 Change PreferredDescriptor of MaxDistance from to RollOffMaxDistance
- 599 Change Tags of MaxDistance from [Deprecated] to []
- 599 Change PreferredDescriptor of MaxDistance from RollOffMaxDistance to
- 553 Change PreferredDescriptor of MaxDistance from to RollOffMaxDistance
- 553 Change Default of MaxDistance from to 10000
- 486 Change ThreadSafety of MaxDistance from ReadOnly to ReadSafe
- 462 Change ThreadSafety of MaxDistance from to ReadOnly
- 456 Change Tags of MaxDistance from [] to [Deprecated]
- 220 Add MaxDistance
MinDistance
Type | Default | |
---|---|---|
float | 10 |
The minimum distance at which a 3D Sound (direct child of a BasePart or Attachment) will begin to attenuate. Effectively, the emitter size.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true/false |
History 10
- 601 Change Tags of MinDistance from [] to [Deprecated]
- 601 Change PreferredDescriptor of MinDistance from to RollOffMinDistance
- 599 Change Tags of MinDistance from [Deprecated] to []
- 599 Change PreferredDescriptor of MinDistance from RollOffMinDistance to
- 553 Change PreferredDescriptor of MinDistance from to RollOffMinDistance
- 553 Change Default of MinDistance from to 10
- 486 Change ThreadSafety of MinDistance from ReadOnly to ReadSafe
- 462 Change ThreadSafety of MinDistance from to ReadOnly
- 262 Change Tags of MinDistance from [] to [Deprecated]
- 220 Add MinDistance
Pause
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Sets Sound.Playing to false. This pauses the playback of the Sound if the sound is playing. Unlike Sound:Stop() it does not reset Sound.TimePosition meaning the sound can be resumed using Sound:Resume().
The impact of the different Sound functions on Sound.Playing and Sound.TimePosition are shown below.
Function | Sound.Playing | Sound.TimePosition |
---|---|---|
Sound:Play() | True | Last value set in Lua (default 0) |
Sound:Pause() | False | - |
Sound:Resume() | True | - |
Sound:Stop() | False | 0 |
Thread safety | Unsafe |
---|
Paused
Parameters (1) | |
---|---|
soundId | string |
Fires whenever the Sound is paused using Sound:Pause().
As with Sound.Played, Sound.Resumed and Sound.Stopped only the respective sound function will cause the event to fire. This means that Pause will only fire when Sound:Pause() is called.
Thread safety | Unsafe |
---|
Pitch
Type | Default | |
---|---|---|
float | 1 |
Sets how high pitched and fast a Sound is when it is played. The greater the integer, the higher and faster the sound is.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true/false |
Play
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Plays the Sound. Sets Sound.TimePosition to the last value set by a Script (or 0 if it has not been set), and then sets Sound.Playing to true.
The impact of the different Sound functions on Sound.Playing and Sound.TimePosition are shown below.
Function | Sound.Playing | Sound.TimePosition |
---|---|---|
Sound:Play() | True | Last value set in Lua (default 0) |
Sound:Pause() | False | - |
Sound:Resume() | True | - |
Sound:Stop() | False | 0 |
Thread safety | Unsafe |
---|
PlayOnRemove
Type | Default | |
---|---|---|
bool | false |
When true, the Sound will play when it is removed from the game.
Note the sound will play when the Instance.Parent property of the Sound or one of its ancestors is set to nil. This means all of the following will cause the sound to play when PlayOnRemove is true. Note, this includes Instance:Destroy() as the destroy function sets the parent to nil.
sound:Destroy()
sound.Parent = nil
sound.Parent.Parent = nil
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of PlayOnRemove from to false
- 486 Change ThreadSafety of PlayOnRemove from ReadOnly to ReadSafe
- 462 Change ThreadSafety of PlayOnRemove from to ReadOnly
- 47 Add PlayOnRemove
PlaybackLoudness
Type | Default | |
---|---|---|
double | 0 |
A number between 0 and 1000 indicating how loud the Sound is currently playing back.
This property reflects the amplitude of the sound's playback in the instance of time it is read. Therefore, for most sounds it will fluctuate constantly. Due to this it can appear in the Roblox Studio properties window as 0, however when read by code in the command bar or Scripts it will return the correct value.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | false |
History 5
- 553 Change Default of PlaybackLoudness from to 0
- 553 Change Category of PlaybackLoudness from Data to Playback
- 486 Change ThreadSafety of PlaybackLoudness from ReadOnly to ReadSafe
- 462 Change ThreadSafety of PlaybackLoudness from to ReadOnly
- 264 Add PlaybackLoudness
PlaybackRegion
Type | Default | |
---|---|---|
NumberRange | 0 60000 |
A range denoting a desired start (min) and stop (max) time within the Sound.TimeLength, in seconds.
If PlaybackRegion.Min > 0, the sound begins to play from the PlaybackRegion.Min time.
If PlaybackRegion.Min < 0, the sound begins to play from 0.
If PlaybackRegion.Max > Sound.TimeLength, the sound stops at Sound.TimeLength.
If PlaybackRegion.Max < Sound.TimeLength, the sound stops at exactly that time.
If PlaybackRegion.Min == PlaybackRegion.Max, the PlayBackRegion is inactive.
Thread safety | ReadSafe |
---|---|
Category | Regions |
Loaded/Saved | true |
History 2
- 553 Change Default of PlaybackRegion from to NumberRange(0 60000 )
- 549 Add PlaybackRegion
PlaybackRegionsEnabled
Type | Default | |
---|---|---|
bool | false |
If true, this property gives your Sound access to the Sound.PlaybackRegion and Sound.LoopRegion properties, which can more-accurately control its playback.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
History 3
- 582 Change Tags of PlaybackRegionsEnabled from [NotBrowsable] to []
- 553 Change Default of PlaybackRegionsEnabled from to false
- 549 Add PlaybackRegionsEnabled
PlaybackSpeed
Type | Default | |
---|---|---|
float | 1 |
Determines the speed at which a Sound will play. The greater the value the faster the sound will play back.
For example, a value of 2 will cause the Sound to play 2x faster, whereas a value of 0.5 will cause it to play 2x slower. When PlaybackSpeed is equal to 1, the sound will take Sound.TimeLength (in seconds) to complete.
Note that increasing the PlaybackSpeed of a sound will cause it to play at a higher pitch.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
History 6
- 553 Change Category of PlaybackSpeed from Data to Playback
- 553 Change Default of PlaybackSpeed from to 1
- 486 Change ThreadSafety of PlaybackSpeed from ReadOnly to ReadSafe
- 462 Change ThreadSafety of PlaybackSpeed from to ReadOnly
- 389 Change Tags of PlaybackSpeed from [] to [NotReplicated]
- 262 Add PlaybackSpeed
Played
Parameters (1) | |
---|---|
soundId | string |
Fires whenever the Sound is played using the Sound:Play() function.
As with Sound.Stopped, Sound.Paused and Sound.Resumed only the respective sound function will cause the event to fire. This means that Played will only fire when Sound:Play() is called. This event will not fire if the Sound is played due to the sound being destroyed and Sound.PlayOnRemove being set to true.
Thread safety | Unsafe |
---|
Playing
Type | Default | |
---|---|---|
bool | false |
Indicates whether the Sound is currently playing. This can be toggled, and this property will always replicate.
In the studio editor, Sounds are not playable because time is halted. Setting Sound.Playing to true in edit mode doesn't do anything. However, you can play audio from within plugins by setting the Sounds as descendants of a PluginGui.
This property should not be confused with Sound.IsPlaying which is a read-only property. Playing can be set to true or false to start or stop the playback of a sound.
Note that when Playing is set to false, the Sound.TimePosition property of the sound will not reset. This means when the Playing is set to true again the audio will continue from the time position it was at when it was stopped. However, if the Sound:Play() function is used to resume the sound the time position will reset to 0.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
Resume
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Resumes the Sound. Sets Sound.Playing to true. Does not alter Sound.TimePosition and thus can be used to resume the playback of a sound stopped using Sound:Pause().
The impact of the different sound functions on Sound.Playing and Sound.TimePosition are shown below.
Function | Sound.Playing | Sound.TimePosition |
---|---|---|
Sound:Play() | True | Last value set in Lua (default 0) |
Sound:Pause() | False | - |
Sound:Resume() | True | - |
Sound:Stop() | False | 0 |
Thread safety | Unsafe |
---|
Resumed
Parameters (1) | |
---|---|
soundId | string |
Fires when the Sound is resumed using Sound:Resume().
As with Sound.Played, Sound.Paused and Sound.Stopped only the respective sound function will cause the event to fire. This means that Resumed will only fire when Sound:Resume() is called.
Thread safety | Unsafe |
---|
RollOffMaxDistance
Type | Default | |
---|---|---|
float | 10000 |
The maximum distance, in studs, a client's listener can be from the Sound origin and still hear it. Only applies to Sounds parented to a Part or Attachment (3D sounds).
How RollOffMaxDistance impacts the attenuation of a sound (manner in which it fades out) is dependent on the Sound.RollOffMode property. When RollOffMode is set to use an inverse type distance model (Inverse or InverseTapered) the RollOffMaxDistance will not effect the attenuation of the sound. This means that low values for RollOffMaxDistance will cause the sound to abruptly cut off when the listener reaches the RollOffMaxDistance. In most cases this is not desirable and developers are advised not to use low RollOffMaxDistance values.
When RollOffMode is set to a linear type distance model (Linear or LinearSquared) the sound will attenuate between Sound.EmitterSize and MaxDistance (with playback volume reaching zero at RollOffMaxDistance). This is less realistic, but in some cases allows attenuation to be handled in a more intuitive way.
Thread safety | ReadSafe |
---|---|
Category | Emitter |
Loaded/Saved | true |
History 8
- 648 Change CanLoad of RollOffMaxDistance from false to true
- 648 Change Tags of RollOffMaxDistance from [NotReplicated] to []
- 648 Change CanSave of RollOffMaxDistance from false to true
- 553 Change Default of RollOffMaxDistance from to 10000
- 553 Change Category of RollOffMaxDistance from Data to Emitter
- 486 Change ThreadSafety of RollOffMaxDistance from ReadOnly to ReadSafe
- 462 Change ThreadSafety of RollOffMaxDistance from to ReadOnly
- 456 Add RollOffMaxDistance
RollOffMinDistance
Type | Default | |
---|---|---|
float | 10 |
The minimum distance, in studs, at which a 3D Sound (direct child of a BasePart or Attachment) will begin to attenuate (decrease in volume).
Sounds parented to a BasePart or Attachment that are descendants of the Workspace are considered 3D sounds and their volume while playing is dependent on the distance between the client's sound listener (Camera position by default) and the Sound's parent. Three properties influence this behavior RollOffMinDistance, Sound.RollOffMaxDistance, and Sound.RollOffMode.
The way the Sound attenuates (fades out) after the distance between the listener and the sound exceeds the RollOffMinDistance is determined by the RollOffMode.
Thread safety | ReadSafe |
---|---|
Category | Emitter |
Loaded/Saved | true |
History 8
- 648 Change Tags of RollOffMinDistance from [NotReplicated] to []
- 648 Change CanSave of RollOffMinDistance from false to true
- 648 Change CanLoad of RollOffMinDistance from false to true
- 553 Change Category of RollOffMinDistance from Data to Emitter
- 553 Change Default of RollOffMinDistance from to 10
- 486 Change ThreadSafety of RollOffMinDistance from ReadOnly to ReadSafe
- 462 Change ThreadSafety of RollOffMinDistance from to ReadOnly
- 456 Add RollOffMinDistance
RollOffMode
Type | Default | |
---|---|---|
RollOffMode | Inverse |
This property sets how 3D Sounds attenuate (fade out) as the distance between the listener and the sound's parent increase. It can be set to one of the values of the RollOffMode enum.
The following code will set RollOffMode to Linear:
1
|
|
The different modes
The following options are available:
Mode | Description |
---|---|
Inverse | Volume attenuates from Sound/RollOffMinDistance in an inverse manner. |
InverseTapered | A hybrid model. Follows the Inverse model when close to RollOffMinDistance and the Linear Square model when close to Sound/RollOffMaxDistance . |
Linear | Volume attenuates between RollOffMinDistance and Sound/RollOffMaxDistance with a linear relationship. |
LinearSquare | Volume attenuates between RollOffMinDistance and Sound/RollOffMaxDistance with a linear squared relationship. |
Inverse vs Linear Distance Attenuation
By default sounds are set to use inverse distance attenuation (Enum.RollOffMode.Inverse) which mirrors how sounds attenuate in the real world. Under inverse distance attenuation, sounds will begin to attenuate once the distance between the listener and the Sound's parent exceeds RollOffMinDistance. The rate of attenuation depends on the emitter size, as sounds with larger EmitterSize's will attenuate at a slower rate. Inverse rate of inverse distance attenuation is further influenced by SoundService.RolloffScale.
RollOffMaxDistance will not effect attenuation under the inverse model but will cause the sound to cut off completely once this distance is reached. This can be particularly abrupt when using low values for max distance.
Linear distance attenuation works differently. Under linear distance attenuation the sound will attenuate between RollOffMinDistance and RollOffMaxDistance, falling silent once MaxDistance is reached. RollOffMinDistance still denotes the point at which the sound will begin attenuating. However, the audible volume at any point now depends on the point the listener is at between EmitterSize and MaxDistance. This means, in contrast to the inverse distance attenuation model, the audible volume of the sound will approach silence at MaxDistance point. This is less realistic, but may be more desirable in some cases.
Thread safety | ReadSafe |
---|---|
Category | Emitter |
Loaded/Saved | true |
History 6
- 553 Change Category of RollOffMode from Data to Emitter
- 553 Change Default of RollOffMode from to Inverse
- 486 Change ThreadSafety of RollOffMode from ReadOnly to ReadSafe
- 462 Change ThreadSafety of RollOffMode from to ReadOnly
- 266 Change Tags of RollOffMode from [Hidden] to []
- 249 Add RollOffMode
SoundGroup
Type | Default | |
---|---|---|
SoundGroup |
The SoundGroup that is linked to this Sound. SoundGroup.Volume and SoundEffects applied to this sound group will pass onto the sound. A sound can only be in one sound group at a time.
SoundGroups are used to manage the volume and effects of multiple Sounds at once. A Sound is added to a SoundGroup by setting the SoundGroup property of the sound.
Thread safety | ReadSafe |
---|---|
Category | Routing |
Loaded/Saved | true |
History 6
- 553 Change Category of SoundGroup from Data to Routing
- 553 Change Default of SoundGroup from to
- 486 Change ThreadSafety of SoundGroup from ReadOnly to ReadSafe
- 462 Change ThreadSafety of SoundGroup from to ReadOnly
- 329 Change ValueType of SoundGroup from Object to SoundGroup
- 264 Add SoundGroup
SoundId
Type | Default | |
---|---|---|
ContentId |
This property is the content ID of the sound file a Sound object is associated with. Once a sound has been uploaded to Roblox the content ID can be found in the uploaded sound's URL.
It's important to remember the URL is not the same as the content ID. It will work when pasted directly into the SoundId property of a Sound in Roblox studio, as Studio will automatically correct it, however if it is being set from a Script then the correct content ID will need to be used, using the number from the URL. For example:
1 2 3 |
|
Thread safety | ReadSafe |
---|---|
Category | Asset |
Loaded/Saved | true |
Stop
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Stops the Sound. Sets Sound.Playing to false then sets Sound.TimePosition to 0.
The impact of the different sound functions on Sound.Playing and Sound.TimePosition are shown below.
Function | Sound.Playing | Sound.TimePosition |
---|---|---|
Sound:Play() | True | Last value set in Lua (default 0) |
Sound:Pause() | False | - |
Sound:Resume() | True | - |
Sound:Stop() | False | 0 |
Thread safety | Unsafe |
---|
Stopped
Parameters (1) | |
---|---|
soundId | string |
Fires when the Sound is stopped due to the Sound:Stop() function.
As with Sound.Played, Sound.Paused and Sound.Resumed only the respective sound function will cause the event to fire. This means that Stopped will only fire when Sound:Stop() is called. Destroying a sound while it is playing will not cause this event to fire.
Thread safety | Unsafe |
---|
TimeLength
Type | Default | |
---|---|---|
double | 0 |
The length of the Sound in seconds. If the Sound is not loaded, this value will be 0.
This property is often used in conjunction with Sound.PlaybackSpeed to adjust the speed of a sound so it lasts for a specific duration (see examples). When Sound.PlaybackSpeed is equal to 1, the sound will take TimeLength seconds to complete.
Thread safety | ReadSafe |
---|---|
Category | Asset |
Loaded/Saved | false |
History 6
- 553 Change Category of TimeLength from Data to Asset
- 553 Change Default of TimeLength from to 0
- 486 Change ThreadSafety of TimeLength from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TimeLength from to ReadOnly
- 178 Change ValueType of TimeLength from int to double
- 176 Add TimeLength
TimePosition
Type | Default | |
---|---|---|
double | 0 |
Shows the progress in seconds of the Sound. Can be changed to move the playback position of the sound. If the sound is already playing then playback will snap to the specified position. If it is not playing the Sound will begin playback at the set position when the sound is next played.
As a Sound is played, TimePosition increases at a rate of Sound.PlaybackSpeed per second. Once TimePosition reaches Sound.TimeLength the Sound will stop unless it is looped. This means, unless Sound.Looped is set to true setting TimePosition to a value equal or greater to Sound.TimeLength will stop the sound.
Note that setting TimePosition
to a value greater than the length in a
looped track will not cause it to wrap around. If that behavior is desired
the developer should do the following.
if newPosition >= sound.TimeLength then
newPosition = newPosition - sound.TimeLength
end
sound.TimePosition = newPosition
Setting TimePosition to a value less than zero currently does not influence playback, but this behavior should not be relied upon.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
History 7
- 553 Change Category of TimePosition from Data to Playback
- 553 Change Default of TimePosition from to 0
- 486 Change ThreadSafety of TimePosition from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TimePosition from to ReadOnly
- 417 Change Tags of TimePosition from [] to [NotReplicated]
- 178 Change ValueType of TimePosition from int to double
- 176 Add TimePosition
Volume
Type | Default | |
---|---|---|
float | 0.5 |
The volume of the Sound. Can be set between 0 and 10. Defaults to 0.5
Note that if the Sound is a member of a SoundGroup its playback volume (but not the Volume property) will be influenced by the SoundGroup.Volume property of that SoundGroup. The effect of this is multiplicative, meaning that a sound will play at the same volume if its Volume is 0.1 and its SoundGroup volume is 5 and vice-versa.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
isPlaying
Type | Default | |
---|---|---|
bool | false |
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
pause
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
play
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
stop
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Thread safety | Unsafe |
---|