Sound
Inherits from DynamicInstance
Sounds are objects that can be placed in the world and emit audio.
Summary
Properties
Autoplay:boolLoading:boolRead OnlyLength:floatRead OnlyLoop:boolPitch:floatPlayInWorld:boolMaxDistance:floatPlaying:boolRead OnlySoundID:stringTime:floatVolume:float
Methods
Play:void:voidPlayOneShot:voidStop:void:void
Events
Loaded:void
Properties
Autoplay
Sound.Autoplay: bool
Determines whether the sound should start playing automatically.
Loading
Sound.Loading: bool
Returns whether or not the sound is loading or not.
Length
Sound.Length: float
Returns the length of the currently loaded audio.
Loop
Sound.Loop: bool
Determines whether the sound should loop or not.
Pitch
Sound.Pitch: float
The pitch of the sound.
PlayInWorld
Sound.PlayInWorld: bool
When enabled, the sound will be played in 3D world space rather than having the same volume for everyone.
MaxDistance
Sound.MaxDistance: float
Specifies how far the player must be from the sound for it to stop playing, if the PlayInWorld property is set to true.
Playing
Sound.Playing: bool
Determines whether the sound is currently playing or not.
SoundID
Sound.SoundID: string
The asset ID of the sound.
Time
Sound.Time: float
The time position the track is currently on.
Volume
Sound.Volume: float
The volume of the sound.
Methods
Play:void
Sound:Play:void()
Plays the sound.
PlayOneShot
Sound:PlayOneShot(volume: float)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
volume | float | - |
Plays the sound once, able to be ran in rapid succession without stopping existing playback.
Stop:void
Sound:Stop:void()
Stops playing the sound.
Properties
Events
Loaded
Sound.Loaded()
The event that is fired when the sound is loaded from the server.
Example
sound.Loaded:Connect(function()
sound.Play()
end)