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

How would I stop all playing sounds?

Asked by 10 years ago

I have a script that randomly picks a song and plays it, if I do the same thing and add :Stop() it will just randomly pick a song to stop. How could I get all running sounds and stop them?

1 answer

Log in to vote
0
Answered by 10 years ago

group the songs together in a table. Use a for statement. Make them all stop.

local songs = script.Parent.Songs:GetChildren()

for _,u in ipairs(songs) do
    if u.ClassName == "Sound" then
        u:stop()
    end
end
Ad

Answer this question