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

Stopped

Fires when the Sound is stopped due to the Sound/Stop function.

As with Sound/Played, Sound/Paused and Sound/Resumed only the respective sound function will cause the event to fire. This means that Stopped will only fire when Sound/Stop is called. Destroying a sound whilst it is playing will not cause this event to fire.

Parameters

Name Type Default Description

The Sound/SoundId of the Sound that stopped.


Code Samples


Sound Functions

This sample gives a simple demonstration of what each of the Sound functions (Sound.Play, Sound.Stop, Sound.Pause and Sound.Resume) do to Sound.Playing and Sound.TimePosition.

-- create a sound
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://301964312"

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

-- listen for events
sound.Played:Connect(function(soundId)
	print("Sound.Played event")
end)

sound.Paused:Connect(function(soundId)
	print("Sound.Paused event")
end)

sound.Resumed:Connect(function(soundId)
	print("Sound.Resumed event")
end)

sound.Stopped:Connect(function(soundId)
	print("Sound.Stopped event")
end)

sound:Play()
print("play", sound.Playing, sound.TimePosition) -- play true 0

wait(10)

sound:Pause()
print("pause", sound.Playing, sound.TimePosition) -- pause false 10

wait(3)

sound:Resume()
print("play", sound.Playing, sound.TimePosition) -- play true 10

wait(3)

sound:Stop()
print("stop", sound.Playing, sound.TimePosition) -- stop false 0

wait(3)

sound:Play()
print("play", sound.Playing, sound.TimePosition) -- play true 0