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

My for loop doesn't mute all the sounds inside of a folder?

Asked by 3 years ago

I’ve recently been working on a system where, when you click on a mute button, it mutes every sound inside of a folder. And for some reason, the for loop that I use for muting all the sounds isn’t looping through all of the sounds. It only mutes every other sound inside of the folder. Here’s the code:

Music.MouseButton1Click:Connect(function()
    for _, music in pairs(script.Parent.Music:GetChildren()) do
        if music.Volume == 0.5 and Music.Frame.Visible == false then
            music.Volume = 0
            Music.Frame.Visible = true
        else
            music.Volume = 0.5
            Music.Frame.Visible = false
        end
    end
end)

1 answer

Log in to vote
0
Answered by
TudiPYM 12
3 years ago

Maybe you try to put those sounds inside of a table, and connect that to your for loop.

Ad

Answer this question