Sound
Plays audio with positional or non-positional output.
- Creatable
Instance.new("Sound")- Inherits
- Instance
- Replication
- Standard
Behavior
Sound plays the clip identified by Asset. A sound parented to a part is
positional and attenuates with distance. A sound under
SoundService or ScreenGui is non-positional.
Destroy temporary sounds after playback. Debris:AddItem currently accepts
parts only.
Summary
The audio asset identifier.
The clip duration in seconds.
Whether the sound restarts after reaching its end.
Whether the sound plays when removed from the hierarchy.
The current playback position in seconds.
The nonnegative playback rate multiplier.
Whether the clip is playing.
The attenuation curve between RolloffMinDistance and RolloffMaxDistance.
The maximum audible distance for positional audio, in studs.
The full-volume distance for positional audio, in studs.
The SoundGroup whose volume multiplier applies to this sound.
The playback volume multiplier, clamped to 0 through 10.
Creates an AudioStream for queued PCM playback by this Sound.
Returns this instance if it is an ExecutionGroup.
Pauses playback and retains PlaybackPosition.
Starts playback from position 0.
Plays the sound at the supplied audio-clock time.
Continues paused playback from the retained position.
Replaces the sound's audio with PCM samples.
Stops playback and resets PlaybackPosition to the beginning.
Fires when a looping sound reaches its end and starts the next loop.
Fires when a non-looping clip reaches the end.
Fires when playback is paused.
Fires when playback starts.
Fires when playback is stopped.
Properties
Asset
Sound.Asset: Content = ""The audio asset identifier. Assignment resets the cached Duration to 0 until the new asset is loaded.
Duration
Sound.Duration: number = 0The clip duration in seconds. Returns 0 until the asset has loaded.
Looped
Sound.Looped: boolean = falseWhether the sound restarts after reaching its end.
PlayOnRemove
Sound.PlayOnRemove: booleanWhether the sound plays when removed from the hierarchy.
PlaybackPosition
Sound.PlaybackPosition: number = 0The current playback position in seconds. Assignment seeks and clamps negative values to 0. Play resets it to 0.
PlaybackSpeed
Sound.PlaybackSpeed: number = 1The nonnegative playback rate multiplier. A value of 2 doubles playback rate and halves duration. Playback rate also affects pitch.
Playing
Sound.Playing: boolean = falseWhether the clip is playing. Returns false while paused.
RollOffMode
Sound.RollOffMode: Enum.RollOffMode = Enum.RollOffMode.InverseThe attenuation curve between RolloffMinDistance and RolloffMaxDistance. See Enum.RollOffMode.
RolloffMaxDistance
Sound.RolloffMaxDistance: number = 100The maximum audible distance for positional audio, in studs. Values below RolloffMinDistance are clamped to that minimum.
RolloffMinDistance
Sound.RolloffMinDistance: number = 10The full-volume distance for positional audio, in studs. Assignment clamps to at least 0 and raises RolloffMaxDistance if necessary.
SoundGroup
Sound.SoundGroup: SoundGroup? = nilThe SoundGroup whose volume multiplier applies to this sound.
Volume
Sound.Volume: number = 0.5The playback volume multiplier, clamped to 0 through 10. A value of 1 uses the clip level. Higher values can cause clipping.
Methods
CreateStream
Sound:CreateStream(sampleRate: number?, channels: number?): AudioStreamCreates an AudioStream for queued PCM playback by this Sound.
GetExecutionGroup
Sound:GetExecutionGroup(): ExecutionGroup?Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.
Pause
Sound:Pause(): ()Pauses playback and retains PlaybackPosition. Call Resume to continue.
Play
Sound:Play(): ()Starts playback from position 0. Calling during playback restarts the clip. To resume a paused clip without resetting its position, call Resume.
PlayAt
Sound:PlayAt(audioTime: number): ()Plays the sound at the supplied audio-clock time.
Resume
Sound:Resume(): ()Continues paused playback from the retained position.
SetPcm
Sound:SetPcm(samples: (buffer | { number })?, sampleRate: number?, channels: number?): ()Replaces the sound's audio with PCM samples. Accepts a buffer of little-endian 32-bit floats or an array of numbers, with sample rate and channel count.
Stop
Sound:Stop(): ()Stops playback and resets PlaybackPosition to the beginning.
Events
DidLoop
Sound.DidLoop: RBXScriptSignalFires when a looping sound reaches its end and starts the next loop.
Ended
Sound.Ended: RBXScriptSignalFires when a non-looping clip reaches the end. Looping playback does not fire this event.
Paused
Sound.Paused: RBXScriptSignalFires when playback is paused.
Played
Sound.Played: RBXScriptSignalFires when playback starts.
Stopped
Sound.Stopped: RBXScriptSignalFires when playback is stopped.
Inherited members
- Properties
- ArchivableClassNameNameParent
- Methods
- AddComponent()AddTag()ClearAllChildren()ClearTags()Clone()Destroy()FindFirstAncestor()FindFirstAncestorOfClass()FindFirstAncestorWhichIsA()FindFirstChild()FindFirstChildOfClass()FindFirstChildWhichIsA()FindFirstDescendant()GetAttribute()GetAttributeChangedSignal()GetAttributes()GetChildren()GetComponent()GetComponentChangedSignal()GetComponents()GetDebugId()GetDescendants()GetFullName()GetPropertyChangedSignal()GetReferencing()GetTags()HasComponent()HasTag()IsA()IsAncestorOf()IsDescendantOf()RemoveComponent()RemoveTag()SetAttribute()WaitForChild()
- Events
- AncestryChangedAttributeChangedChangedChildAddedChildRemovedDescendantAddedDescendantRemovingDestroying
Example
local sound = Instance.new("Sound")
sound.Asset = "rbxassetid://9120386436"
sound.Parent = game:GetService("SoundService")
sound:Play()