Class · inherits Instance
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.
About Sound
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 20
AudioContent
: ContentHiddenA reference to an audio asset.This property is a reference to an audio asset.
IsLoaded
: booleanReadOnlyNotReplicatedThis property istruewhen theSoundhas loaded from Roblox servers and is ready to play.IsPaused
: booleanHiddenReadOnlyNotReplicatedRead-only property which returnstruewhen theSoundis not playing.This read-only property returns
truewhen theSoundis not playing. Note that it can returntrueif a sound has been paused usingPause(), if it has been stopped usingStop(), or the sound has never been played.As
IsPausedis read-only, it cannot be used to stop the sound;Stop()orPause()should be used instead.Looped
: booleanSets whether or not theSoundrepeats once it has finished playing.LoopRegion
: NumberRangeA range denoting a desired loop start and loop end within thePlaybackRegion, in seconds.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.
PlaybackLoudness
: doubleReadOnlyNotReplicatedA number between0and1000indicating how loud theSoundis currently playing back.A number between
0and1000indicating how loud theSoundis currently playing back. This property reflects the amplitude of the sound's playback in the instance of time it is read.PlaybackRegion
: NumberRangeA range denoting a desired start and stop time within theTimeLength, in seconds.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
: booleanIftrue, this property gives yourSoundaccess to thePlaybackRegionandLoopRegionproperties which can more-accurately control its playback.PlaybackSpeed
: floatNotReplicatedDetermines the speed at which aSoundwill play, with higher values causing the sound to play faster and at a higher pitch.Playing
: booleanNotReplicatedIndicates whether theSoundis currently playing.Indicates whether the
Soundis currently playing. This can be toggled, and this property will always replicate.In Studio's Properties window, while in Edit mode, toggling
Playingtotruedoes not begin playing the sound, but the sound will begin playing during runtime.This property should not be confused with
IsPlayingwhich is a read-only property.Note that when
Playingis set tofalse, theTimePositionproperty of the sound will not reset, meaning that whenPlayingis set totrueagain, the audio will continue from the time position it was at when it was stopped. However, if thePlay()function is used to resume the sound, the time position will reset to0.PlayOnRemove
: booleanWhentrue, theSoundwill play when it is removed from the experience.When
true, theSoundwill play when it is removed from the experience by parenting theSoundor one if its ancestors tonil. This means all of the following will cause the sound to play whenPlayOnRemoveistrue:sound:Destroy()sound.Parent = nilsound.Parent.Parent = nil
RollOffMaxDistance
: floatThe maximum distance, in studs, a client's listener can be from the sound's origin and still hear it. Only applies toSoundsparented to aBasePartorAttachment.The maximum distance, in studs, a client's listener can be from the sound's origin and still hear it. Only applies to
Soundsparented to aBasePartorAttachment.How
RollOffMaxDistanceimpacts the attenuation of a sound (manner in which it fades out) is dependent on theRollOffModeproperty.RollOffMinDistance
: floatThe minimum distance, in studs, at which aSoundwhich is parented to aBasePartorAttachmentwill begin to attenuate (decrease in volume).The minimum distance, in studs, at which a
Soundwhich is parented to aBasePartorAttachmentwill begin to attenuate (decrease in volume).How
RollOffMinDistanceimpacts the attenuation of a sound (manner in which it fades out) is dependent on theRollOffModeproperty.RollOffMode
: RollOffModeControls how the volume of aSoundwhich is parented to aBasePartorAttachmentattenuates (fades out) as the distance between the listener and parent changes.This property controls how the volume of a
Soundwhich is parented to aBasePartorAttachmentattenuates (fades out) as the distance between the listener and parent changes.For details on the different modes, see
RollOffMode.SoundGroup
: SoundGroupTheSoundGroupthat is linked to thisSound.SoundId
: ContentIdContent ID of the sound file to associate with theSound.This property is the content ID of the sound file to associate with the
Sound. See Audio Assets for more information.TimeLength
: doubleReadOnlyNotReplicatedThe length of theSoundin seconds.The length of the
Soundin seconds. If theSoundis not loaded, this value will be0.This property is often used in conjunction with
PlaybackSpeedto adjust the speed of a sound so that it lasts for a specific duration.TimePosition
: doubleNotReplicatedProgress of theSoundin seconds. Can be changed to move the playback position of theSoundboth before and during playback.This property reflects the progress of the
Soundin seconds. It can be changed to move the playback position of the sound both before and during playback.As a
Soundis played,TimePositionincreases at a rate ofPlaybackSpeedper second. OnceTimePositionreachesTimeLength, the sound will stop unless it isLooped.Note that setting
TimePositionto 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
: floatThe volume of theSound.The volume of the
Sound. Can be set between0and10and defaults to0.5.Note that if the
Soundis a member of aSoundGroup, its playback volume (but not itsVolumeproperty) will be influenced by the group'sSoundGroup.Volumeproperty.
Methods 4
Play
() → ()Plays theSound.This method plays the
Soundand setsTimePositionto the last value set by a script (or0if it has not been set), then setsPlayingtotrue.Resume
() → ()Resumes theSound.This method resumes the
Soundand setsPlayingtotrue. Does not alterTimePositionand thus can be used to resume playback of a sound paused throughPause().Stop
() → ()Stops theSound.This method stops the
Soundand setsPlayingtofalse, then setsTimePositionto0.
Events 7
DidLoop
Sound.DidLoop:Connect(function(soundId, numOfTimesLooped))Fires whenever theSoundloops.Ended
Sound.Ended:Connect(function(soundId))Fires when theSoundhas completed playback and stopped.Fires when the
Soundhas 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
Loopedset totrue, 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 theStoppedevent.
Sound also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.