PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Playing

Sound

bool

Indicates whether the Sound is currently playing. This can be toggled, and this property will always replicate.

This property should not be confused with Sound/IsPlaying which is a read-only property. Playing can be set to true or false to start or stop the playback of a sound.

Note that when Playing is set to false, the Sound/TimePosition property of the sound will not reset. This means when the Playing is set to true again the audio will continue from the time position it was at when it was stopped. However, if the Sound/Play function is used to resume the sound the time position will reset to 0.


Code Samples


Sound Playing

This sample demonstrates how the Sound.Playing property can be used to start and stop playback of a sound.

A sound is instanced in the Workspace and playback is started by setting Sound.Playing to true. After ten seconds the playback is stopped by setting Sound.Playing to false. When the playback is again resumed using Sound.Playing it resumes at the previous Sound.TimePosition it was stopped at. This is demonstrated by printing the TimePosition property immediately after resuming the sound.

local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://301964312"
sound.Looped = true

print("playing sound")
sound.Playing = true

wait(10)

print("stopping sound")
sound.Playing = false

wait(5)

sound.Playing = true
local timePosition = sound.TimePosition
print("resumed at time position: "..tostring(timePosition)) -- c. 10 seconds