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

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

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

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

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