API:Class/Sound

Sound icon.pngSound : Object Icon.pngInstance

A sound is an object that emits sound. A sound placed in Part will emit its sound from that part. If in a part, sounds have a Doppler effect, meaning that if they are speeding toward you they will get louder and be slightly higher in pitch, and if they are speeding away they will get quieter and lower in pitch.

If a sound is not in a Part, then it plays at the same volume throughout the entire place.

Sounds can be uploaded in either .mp3 or .ogg formats. See Sounds for more info on how to upload a sound file.

TimePosition, TimeLength, Playing will all properly replicate when set from the server.

Properties

PropertiesmemberhiddenProperties [toggle]

floatEmitterSize

The minimum distance at which a 3D Sound (direct child of a Part) will begin to attenuate (decrease in volume).

boolIsLoaded [ readonly ]

Indicates if the Sound has been loaded.

boolIsPaused [ readonly ]

This property will return true when the sound is not playing.

boolIsPlaying [ readonly ]

This property will return true when the sound is playing.

boolLooped

This sets whether or not the sound repeats after a script tells it to Play.

floatMaxDistance

The maximum distance you can be from the sound's origin to hear it.

boolPlayOnRemove

When true, the sound will play when it is removed from the game.

doublePlaybackLoudness [ readonly ]

A number between 0 and 1000 indicating how loud the sound is currently playing back.

floatPlaybackSpeed

Sets how quickly the sound is played back.

boolPlaying

Indicates whether the sound is currently playing. This can be toggled, and this property will always replicate, even with Experimental Mode disabled.

RollOffModeRollOffMode

Controls how the volume of a 3D sound behaves as the distance between the listener and sound changes.

Ref<SoundGroup>SoundGroup

The SoundGroup that is linked to this Sound.

ContentSoundId

The URL of the sound asset to play.

doubleTimeLength [ readonly ]

The length of the sound in seconds. If the sound is not loaded, this value will be 0.

doubleTimePosition

Shows the progress in seconds of the Sound. Can be changed to move the playback position of the Sound.

floatVolume

The volume of the sound. Can be set between 0 and 10.

floatMinDistance [ deprecated ]

Deprecated. Do not use.

floatPitch [ deprecated ]

Deprecated. Do not use.

boolisPlaying [ deprecated ] [ readonly ]

Deprecated in favor of IsPlaying.

The minimum distance at which a 3D Sound (direct child of a Part) will begin to attenuate (decrease in volume).
IsLoaded [ readonly ]
Indicates if the Sound has been loaded.
IsPaused [ readonly ]
This property will return true when the sound is not playing.
IsPlaying [ readonly ]
This property will return true when the sound is playing.
This sets whether or not the sound repeats after a script tells it to Play.
The maximum distance you can be from the sound's origin to hear it.
When true, the sound will play when it is removed from the game.
PlaybackLoudness [ readonly ]
A number between 0 and 1000 indicating how loud the sound is currently playing back.
Sets how quickly the sound is played back.
Indicates whether the sound is currently playing. This can be toggled, and this property will always replicate, even with Experimental Mode disabled.
Controls how the volume of a 3D sound behaves as the distance between the listener and sound changes.
The SoundGroup that is linked to this Sound.
The URL of the sound asset to play.
TimeLength [ readonly ]
The length of the sound in seconds. If the sound is not loaded, this value will be 0.
Shows the progress in seconds of the Sound. Can be changed to move the playback position of the Sound.
The volume of the sound. Can be set between 0 and 10.
MinDistance [ deprecated ]
Deprecated. Do not use.
Pitch [ deprecated ]
Deprecated. Do not use.
isPlaying [ deprecated ] [ readonly ]
Deprecated in favor of IsPlaying.
Inherited from Object Icon.pngInstance:
boolArchivable

Determines if an object can be Cloned or saved to file.

stringClassName [ readonly ]

The unique name of this type of Instance.

stringName

A non-unique identifier for the object.

Ref<Instance>Parent

The hierarchical parent of the object.

intDataCost [ RobloxPlaceSecurity ] [ deprecated ] [ readonly ]

Deprecated. Do not use.

boolRobloxLocked [ PluginSecurity ]

If true, the object and its descendants cannot be indexed or edited by a Script or LocalScript and will throw an error if it is attempted.

boolarchivable [ deprecated ] [ hidden ]

Deprecated in favor of Archivable.

stringclassName [ deprecated ] [ readonly ]

Deprecated in favor of ClassName.

Determines if an object can be Cloned or saved to file.
ClassName [ readonly ]
The unique name of this type of Instance.
A non-unique identifier for the object.
The hierarchical parent of the object.
DataCost [ RobloxPlaceSecurity ] [ deprecated ] [ readonly ]
Deprecated. Do not use.
RobloxLocked [ PluginSecurity ]
If true, the object and its descendants cannot be indexed or edited by a Script or LocalScript and will throw an error if it is attempted.
archivable [ deprecated ] [ hidden ]
Deprecated in favor of Archivable.
className [ deprecated ] [ readonly ]
Deprecated in favor of ClassName.

Functions

FunctionsmemberhiddenFunctions [toggle]

voidPause ( )

Pauses the Sound if it is playing. Sets Playing to false.

voidPlay ( )

Plays the sound. Sets TimePosition to the last value set in lua (default 0), and then sets Playing to true.

voidResume ( )

Resumes the sound. Sets Playing to True.

voidStop ( )

Stops the sound. Sets Playing to false then sets TimePosition to 0.

voidpause ( ) [ deprecated ]

Deprecated in favor of Pause.

voidplay ( ) [ deprecated ]

Deprecated in favor of Play.

voidstop ( ) [ deprecated ]

Deprecated in favor of Stop.

Pause ( )
Pauses the Sound if it is playing. Sets Playing to false.
Play ( )
Plays the sound. Sets TimePosition to the last value set in lua (default 0), and then sets Playing to true.
Resume ( )
Resumes the sound. Sets Playing to True.
Stop ( )
Stops the sound. Sets Playing to false then sets TimePosition to 0.
pause ( ) [ deprecated ]
Deprecated in favor of Pause.
play ( ) [ deprecated ]
Deprecated in favor of Play.
stop ( ) [ deprecated ]
Deprecated in favor of Stop.
Inherited from Object Icon.pngInstance:
voidClearAllChildren ( )

Removes all descendants of the object.

Ref<Instance>Clone ( )

Returns a copy of the object, including descendants, but only if the object is Archivable.

voidDestroy ( )

Sets the Parent property to nil, locks the Parent property, disconnects all connections and calls Destroy() on all children.

Ref<Instance>FindFirstAncestor ( string name )

Returns the first ancestor whose Name is equal to name, or nil if none can be found.

Ref<Instance>FindFirstAncestorOfClass ( string className )

Returns the first ancestor whose ClassName is equal to className, or nil if none can be found.

Ref<Instance>FindFirstAncestorWhichIsA ( string className )

Returns the first ancestor that inherits the class className, or nil if none can be found.

Ref<Instance>FindFirstChild ( string name, bool recursive = false )

Returns the first child found with the given name, or nil if no such child exists. If the optional recursive argument is true, recursively descends the hierarchy while searching rather than only searching the immediate object.

Ref<Instance>FindFirstChildOfClass ( string className )

Returns the first Instance whose ClassName is equal to className, or nil, if no such object is found with that ClassName.

Ref<Instance>FindFirstChildWhichIsA ( string className, bool recursive = false )

Returns the first child that inherits the class className, or nil if none can be found.

array<Instance>GetChildren ( )

Returns an array of the object's children.

array<Instance>GetDescendants ( )

Returns an array containing all of the descendants of the instance.

stringGetFullName ( )

Returns a string which shows the object's ancestry chain.

RBXScriptSignalGetPropertyChangedSignal ( string property )

Returns a signal that is fired when the specified property is changed on this object.

boolIsA ( string className )

Returns true if the object is an instance of the given class, or if the object's class inherits from the given class.

boolIsAncestorOf ( Instance descendant )

Returns true if the object is an ancestor of the given descendant.

boolIsDescendantOf ( Instance ancestor )

Returns true if the object is a descendant of the given ancestor.

Ref<Instance>WaitForChild ( string childName, double timeOut )

Yields the current thread until a child with the given name is found, then returns the child. If the timeOut parameter is specified, this function will time out and return nil if timeOut seconds elapse without the child being found.

stringGetDebugId ( int scopeLength = 4 ) [ PluginSecurity ] [ notbrowsable ]

Returns a coded string of the object's DebugId used internally by Roblox.

voidRemove ( ) [ deprecated ]

Deprecated. Do not use.

array<Instance>children ( ) [ deprecated ]

Deprecated in favor of GetChildren.

Instanceclone ( ) [ deprecated ]

Deprecated in favor of Clone.

voiddestroy ( ) [ deprecated ]

Deprecated in favor of Destroy.

InstancefindFirstChild ( string name, bool recursive = false ) [ deprecated ]

Deprecated in favor of FindFirstChild.

array<Instance>getChildren ( ) [ deprecated ]

Deprecated in favor of GetChildren.

boolisA ( string className ) [ deprecated ]

Deprecated in favor of IsA.

boolisDescendantOf ( Instance ancestor ) [ deprecated ]

Deprecated in favor of IsDescendantOf.

voidremove ( ) [ deprecated ]

Deprecated in favor of Remove.

Removes all descendants of the object.
Clone ( )
Returns a copy of the object, including descendants, but only if the object is Archivable.
Sets the Parent property to nil, locks the Parent property, disconnects all connections and calls Destroy() on all children.
Returns the first ancestor whose Name is equal to name, or nil if none can be found.
Returns the first ancestor whose ClassName is equal to className, or nil if none can be found.
Returns the first ancestor that inherits the class className, or nil if none can be found.
FindFirstChild ( string name, bool recursive = false )
Returns the first child found with the given name, or nil if no such child exists. If the optional recursive argument is true, recursively descends the hierarchy while searching rather than only searching the immediate object.
Returns the first Instance whose ClassName is equal to className, or nil, if no such object is found with that ClassName.
FindFirstChildWhichIsA ( string className, bool recursive = false )
Returns the first child that inherits the class className, or nil if none can be found.
Returns an array of the object's children.
Returns an array containing all of the descendants of the instance.
Returns a string which shows the object's ancestry chain.
Returns a signal that is fired when the specified property is changed on this object.
IsA ( string className )
Returns true if the object is an instance of the given class, or if the object's class inherits from the given class.
IsAncestorOf ( Instance descendant )
Returns true if the object is an ancestor of the given descendant.
Returns true if the object is a descendant of the given ancestor.
WaitForChild ( string childName, double timeOut )
Yields the current thread until a child with the given name is found, then returns the child. If the timeOut parameter is specified, this function will time out and return nil if timeOut seconds elapse without the child being found.
GetDebugId ( int scopeLength = 4 ) [ PluginSecurity ] [ notbrowsable ]
Returns a coded string of the object's DebugId used internally by Roblox.
Remove ( ) [ deprecated ]
Deprecated. Do not use.
children ( ) [ deprecated ]
Deprecated in favor of GetChildren.
clone ( ) [ deprecated ]
Deprecated in favor of Clone.
destroy ( ) [ deprecated ]
Deprecated in favor of Destroy.
findFirstChild ( string name, bool recursive = false ) [ deprecated ]
Deprecated in favor of FindFirstChild.
getChildren ( ) [ deprecated ]
Deprecated in favor of GetChildren.
isA ( string className ) [ deprecated ]
Deprecated in favor of IsA.
isDescendantOf ( Instance ancestor ) [ deprecated ]
Deprecated in favor of IsDescendantOf.
remove ( ) [ deprecated ]
Deprecated in favor of Remove.


Events

EventsmemberhiddenEvents [toggle]

DidLoop ( string soundId, int numOfTimesLooped )

Fires whenever this sound loops.

Ended ( string soundId )

Fires whenever this sound has ended.

Loaded ( string soundId )

Fired when the sound is loaded.

Paused ( string soundId )

Fires whenever this sound is paused.

Played ( string soundId )

Fires whenever a sound gets played.

Resumed ( string soundId )

Fired when the sound is Resumed.

Stopped ( string soundId )

Fires whenever a sound is stopped.

DidLoop ( string soundId, int numOfTimesLooped )
Fires whenever this sound loops.
Ended ( string soundId )
Fires whenever this sound has ended.
Loaded ( string soundId )
Fired when the sound is loaded.
Paused ( string soundId )
Fires whenever this sound is paused.
Played ( string soundId )
Fires whenever a sound gets played.
Resumed ( string soundId )
Fired when the sound is Resumed.
Stopped ( string soundId )
Fires whenever a sound is stopped.
Inherited from Object Icon.pngInstance:
AncestryChanged ( Instance child, Instance parent )

Fires when the Parent property of the object or one of its ancestors is changed.

Changed ( string property )

Fires after a property of the object changes.

ChildAdded ( Instance child )

Fires when a child is added to the object.

ChildRemoved ( Instance child )

Fires when a child is removed from the object.

DescendantAdded ( Instance descendant )

Fires when a descendant is added to the object.

DescendantRemoving ( Instance descendant )

Fires before a descendant of the object is removed.

childAdded ( Instance child ) [ deprecated ]

Deprecated in favor of ChildAdded.

Fires when the Parent property of the object or one of its ancestors is changed.
Changed ( string property )
Fires after a property of the object changes.
Fires when a child is added to the object.
Fires when a child is removed from the object.
DescendantAdded ( Instance descendant )
Fires when a descendant is added to the object.
Fires before a descendant of the object is removed.
childAdded ( Instance child ) [ deprecated ]
Deprecated in favor of ChildAdded.



See also