Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do you make a function onStopped?

Asked by
NotSoNorm 777 Moderation Voter
10 years ago

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

Log in to vote
0
Answered by
Tesouro 407 Moderation Voter
10 years ago

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)
Ad

Answer this question