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

IsPlaying

Sound

bool

This read-only property will return true when the Sound is playing.

This property can only be true when Sound/IsPaused is false.

As IsPlaying is read only it can not be used to play the sound, Sound/Play should be used instead.


Code Samples


Sound IsPlaying and SoundIsPaused

This code sample contains demonstrates when the Sound.IsPlaying and Sound.IsPaused properties will be true or false.

A sound is instanced in the Workspace and the Sound.IsLoaded property is checked to ensure it has loaded, if it has not the Sound.Loaded event is used to yield the script until the sound has.

As the sound is played, paused and stopped the Sound.IsPlaying and Sound.IsPaused properties are printed to demonstrate how they respond to each of these functions. Note Sound.IsPaused will always be true if even if the sound has been stopped rather than paused.

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

if not sound.isLoaded then
	sound.Loaded:wait()
end

sound:Play()
print(sound.IsPlaying, sound.IsPaused) -- true, false

wait(2)
sound:Pause()
print(sound.IsPlaying, sound.IsPaused) -- false, true

wait(2)
sound:Play()
print(sound.IsPlaying, sound.IsPaused) -- true, false

wait(2)
sound:Stop()
print(sound.IsPlaying, sound.IsPaused) -- false, true