Class
Sound
An object that emits sound. This object 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.
Sound is an object that emits sound. When placed in a BasePart
or an Attachment, this object will emit its sound from that part's
BasePart.Position or the attachment's
Attachment.WorldPosition. In this placement, 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. Additionally, its
volume 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, see 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.
Properties 25#
AudioContentContent | A reference to an audio asset.ReadSafeHidden |
EmitterSizefloat | The minimum distance, in studs, at which a 3D Sound (direct child
of a BasePart or Attachment) will begin to attenuate
(decrease in volume).ReadSafeDeprecated |
IsLoadedboolean | This property is true when the Sound has loaded from Roblox
servers and is ready to play.ReadSafeReadOnlyNotReplicated |
IsPausedboolean | Read-only property which returns true when the Sound is not
playing.ReadSafeHiddenReadOnlyNotReplicated |
IsPlayingboolean | Read-only property which returns true when the Sound is playing.ReadSafeHiddenReadOnlyNotReplicated |
isPlayingboolean | ReadSafeDeprecatedReadOnlyNotReplicated |
Loopedboolean | Sets whether or not the Sound repeats once it has finished
playing.ReadSafe |
LoopRegionNumberRange | A range denoting a desired loop start and loop end within the
PlaybackRegion, in seconds.ReadSafe |
MaxDistancefloat | The maximum distance, in studs, a client's listener can be from the
Sound\s origin and still hear it. Only applies to Sounds
parented to a Part or Attachment (3D sounds).ReadSafeDeprecated |
MinDistancefloat | The minimum distance at which a 3D Sound (direct child of a
BasePart or Attachment) will begin to attenuate.
Effectively, the emitter size.ReadSafeDeprecated |
Pitchfloat | Sets how high pitched and fast a Sound is when it is played. The
greater the integer, the higher and faster the Sound is.ReadSafeDeprecated |
PlaybackLoudnessdouble | A number between 0 and 1000 indicating how loud the Sound is
currently playing back.ReadSafeReadOnlyNotReplicated |
PlaybackRegionNumberRange | A range denoting a desired start and stop time within the
TimeLength, in seconds.ReadSafe |
PlaybackRegionsEnabledboolean | If true, this property gives your Sound access to the
PlaybackRegion and
LoopRegion properties which can more-accurately
control its playback.ReadSafe |
PlaybackSpeedfloat | Determines the speed at which a Sound will play, with higher
values causing the sound to play faster and at a higher pitch.ReadSafeNotReplicated |
Playingboolean | Indicates whether the Sound is currently playing.ReadSafeNotReplicated |
PlayOnRemoveboolean | When true, the Sound will play when it is removed from the
experience.ReadSafe |
RollOffMaxDistancefloat | The maximum distance, in studs, a client's listener can be from the
sound's origin and still hear it. Only applies to Sounds
parented to a BasePart or Attachment.ReadSafe |
RollOffMinDistancefloat | The minimum distance, in studs, at which a Sound which is parented
to a BasePart or Attachment will begin to attenuate
(decrease in volume).ReadSafe |
RollOffModeRollOffMode | Controls how the volume of a Sound which is parented to a
BasePart or Attachment attenuates (fades out) as the
distance between the listener and parent changes.ReadSafe |
SoundGroupSoundGroup | The SoundGroup that is linked to this Sound.ReadSafe |
SoundIdContentId | Content ID of the sound file to associate with the Sound.ReadSafe |
TimeLengthdouble | The length of the Sound in seconds.ReadSafeReadOnlyNotReplicated |
TimePositiondouble | Progress of the Sound in seconds. Can be changed to move the
playback position of the Sound both before and during playback.ReadSafeNotReplicated |
Volumefloat | The volume of the Sound.ReadSafe |
AudioContent: Content#
HiddenReadSafe
This property is a reference to an audio asset.
EmitterSize: float#
DeprecatedReadSafeDeprecated
Deprecated. This property has deprecated in favor of Sound.RollOffMinDistance
and Sound.RollOffMaxDistance which should be used instead in new
work.
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.
IsLoaded: boolean#
ReadOnlyNotReplicatedReadSafe
IsPaused: boolean#
HiddenReadOnlyNotReplicatedReadSafe
This read-only property returns true when the Sound is not
playing. Note that it can return true if a sound has been paused using
Pause(), if it has been stopped using
Stop(), or the sound has never been played.
As IsPaused is read-only, it cannot be used to stop
the sound; Stop() or Pause()
should be used instead.
IsPlaying: boolean#
HiddenReadOnlyNotReplicatedReadSafe
isPlaying: boolean#
ReadOnlyNotReplicatedDeprecatedReadSafeDeprecated
Deprecated. This deprecated property is a variant of Sound.IsPlaying which
should be used instead.
Looped: boolean#
ReadSafe
LoopRegion: NumberRange#
ReadSafe
A range denoting a desired loop start and loop end within the
PlaybackRegion, in seconds.
If
LoopRegion.Min>PlaybackRegion.Min, the loop starts fromLoopRegion.Min.If
LoopRegion.Min<PlaybackRegion.Min, the loop starts fromPlaybackRegion.Min.If
LoopRegion.Max>PlaybackRegion.Max, the loop starts atPlaybackRegion.Max.If
LoopRegion.Max<PlaybackRegion.Max, the loop starts at exactly that time.If
LoopRegion.Min==LoopRegion.Max, theSounduses thePlaybackRegionproperty instead.
MaxDistance: float#
DeprecatedReadSafeDeprecated
Deprecated. This property has deprecated in favor of Sound.RollOffMinDistance
and Sound.RollOffMaxDistance which should be used instead in new
work.
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.
MinDistance: float#
DeprecatedReadSafeDeprecated
Deprecated. MinDistance has been superseded by Sound.EmitterSize, whose name
better describes this properties behavior.
The minimum distance at which a 3D Sound (direct child of a
BasePart or Attachment) will begin to attenuate.
Effectively, the emitter size.
Pitch: float#
DeprecatedReadSafeDeprecated
Deprecated. This property has been deprecated in favor of Sound.PlaybackSpeed
whose name suits the behavior better.
Sets how high pitched and fast a Sound is when it is played. The
greater the integer, the higher and faster the sound is.
PlaybackLoudness: double#
ReadOnlyNotReplicatedReadSafe
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.
PlaybackRegion: NumberRange#
ReadSafe
A range denoting a desired start and stop time within the
TimeLength, in seconds.
If
PlaybackRegion.Min>0, the sound begins to play from thePlaybackRegion.Mintime.If
PlaybackRegion.Min<0, the sound begins to play from0.If
PlaybackRegion.Max>Sound.TimeLength, the sound stops atSound.TimeLength.If
PlaybackRegion.Max<Sound.TimeLength, the sound stops at exactly that time.If
PlaybackRegion.Min==PlaybackRegion.Max, this property is inactive.
PlaybackRegionsEnabled: boolean#
ReadSafe
If true, this property gives your Sound access to the
PlaybackRegion and
LoopRegion properties which can more-accurately
control its playback.
PlaybackSpeed: float#
NotReplicatedReadSafe
Determines the speed at which a Sound will play, with higher
values causing the sound to play faster and at a higher pitch.
Playing: boolean#
NotReplicatedReadSafe
Indicates whether the Sound is currently playing. This can be
toggled, and this property will always replicate.
In Studio's Properties window, while in
Edit mode, toggling Playing to true does not
begin playing the sound, but the sound will begin playing during runtime.
This property should not be confused with
IsPlaying which is a read-only property.
Note that when Playing is set to false, the
TimePosition property of the sound will not
reset, meaning that when Playing is set to true
again, the audio will continue from the time position it was at when it
was stopped. However, if the Play() function is used
to resume the sound, the time position will reset to 0.
PlayOnRemove: boolean#
ReadSafe
When true, the Sound will play when it is removed from the
experience by parenting the Sound or one if its ancestors to
nil. This means all of the following will cause the sound to play when
PlayOnRemove is true:
sound:Destroy()sound.Parent = nilsound.Parent.Parent = nil
RollOffMaxDistance: float#
ReadSafe
The maximum distance, in studs, a client's listener can be from the
sound's origin and still hear it. Only applies to Sounds
parented to a BasePart or Attachment.
How RollOffMaxDistance impacts the
attenuation of a sound (manner in which it fades out) is dependent on the
RollOffMode property.
RollOffMinDistance: float#
ReadSafe
The minimum distance, in studs, at which a Sound which is parented
to a BasePart or Attachment will begin to attenuate
(decrease in volume).
How RollOffMinDistance impacts the
attenuation of a sound (manner in which it fades out) is dependent on the
RollOffMode property.
RollOffMode: RollOffMode#
ReadSafe
This property controls how the volume of a Sound which is parented
to a BasePart or Attachment attenuates (fades out) as the
distance between the listener and parent changes.
For details on the different modes, see RollOffMode.
SoundGroup: SoundGroup#
ReadSafe
The SoundGroup that is linked to this Sound.
SoundId: ContentId#
ReadSafe
This property is the content ID of the sound file to associate with the
Sound. See Audio Assets for more
information.
TimeLength: double#
ReadOnlyNotReplicatedReadSafe
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
PlaybackSpeed to adjust the speed of a sound
so that it lasts for a specific duration.
TimePosition: double#
NotReplicatedReadSafe
This property reflects the progress of the Sound in seconds. It
can be changed to move the playback position of the sound both before and
during playback.
As a Sound is played, TimePosition
increases at a rate of PlaybackSpeed per
second. Once TimePosition reaches
TimeLength, the sound will stop unless it is
Looped.
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, consider the following code snippet:
Volume: float#
ReadSafe
The volume of the Sound. Can be set between 0 and 10 and
defaults to 0.5.
Note that if the Sound is a member of a SoundGroup, its
playback volume (but not its Volume property) will be
influenced by the group's SoundGroup.Volume property.
Methods 7#
| Pause | Pauses playback of the Sound if it is playing. |
| pause | Deprecated |
| Play | Plays the Sound. |
| play | Deprecated |
| Resume | Resumes the Sound. |
| Stop | Stops the Sound. |
| stop | Deprecated |
Pause(): ()#
This method pauses playback of the Sound if it is playing, setting
Playing to false. Unlike
Stop(), it does not reset
TimePosition, meaning the sound can be resumed
using Resume().
Returns
()
pause(): ()#
DeprecatedDeprecated
Deprecated. This deprecated function is a variant of Sound:Pause() which
should be used instead.
Returns
()
Play(): ()#
This method plays the Sound and sets
TimePosition to the last value set by a script
(or 0 if it has not been set), then sets Playing
to true.
Returns
()
play(): ()#
DeprecatedDeprecated
Deprecated. This deprecated function is a variant of Sound:Play() which should
be used instead.
Returns
()
Resume(): ()#
This method resumes the Sound and sets
Playing to true. Does not alter
TimePosition and thus can be used to resume
playback of a sound paused through Pause().
Returns
()
Stop(): ()#
This method stops the Sound and sets Playing
to false, then sets TimePosition to 0.
Returns
()
stop(): ()#
DeprecatedDeprecated
Deprecated. This deprecated function is a variant of Sound:Stop() which should
be used instead.
Returns
()
Events 7#
| DidLoop | Fires whenever the Sound loops. |
| Ended | Fires when the Sound has completed playback and stopped. |
| Loaded | Fires when the Sound is loaded. |
| Paused | Fires whenever the Sound is paused using
Pause(). |
| Played | Fires whenever the Sound is played using
Play(). |
| Resumed | Fires when the Sound is resumed using
Resume(). |
| Stopped | Fires when the Sound is stopped through using
Stop(). |
DidLoop(soundId: string, numOfTimesLooped: int)#
Ended(soundId: string)#
Fires when the Sound has completed playback and stopped. This
event is often used to destroy a sound when it has completed playback:
sound:Play()
sound.Ended:Wait()
sound:Destroy()Note that this event will not fire for sounds with
Looped set to true, as they continue playing upon
reaching their end. This event will also not fire when the sound is
stopped before playback has completed; for this use the
Stopped event.
Loaded(soundId: string)#
Paused(soundId: string)#
Played(soundId: string)#
Fires whenever the Sound is played using
Play(). This event will not fire if the
Sound is played due to PlayOnRemove
being set to true and the sound being destroyed.
Resumed(soundId: string)#
Stopped(soundId: string)#
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild