Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do you make a function onStopped?

Is there a way that I can get an event to trigger if the sound is not playing anymore?

while true do
wait(1)
	if script.Parent.Sound.IsPlaying then
		script.Parent.Parent.SongPlayNoter.Visible = true
		script.Parent.Parent.ScrollingFrame.Visible = false
		
	elseif script.Parent.Sound.IsPaused then
		script.Parent.Parent.ScrollingFrame.Visible = true
		script.Parent.Parent.SongPlayNoter.Visible = false
	end
end

1 answer

You can use Changed event instead of a loop.

sound = script.Parent.Sound -- the sound
function changed() -- every time a property of sound changes, this function runs.
	if  sound.IsPlaying == false then -- checks if the sound isn't playing anymore (it stopped)
		-- CODE
	end
end
sound.Changed:connect(changed)

This discussion is preserved as it was. New answers, comments, and votes are closed.