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

Why doesn't this script mute all of the sounds?

Why doesn't this script mute all of the sounds? It is a localscript.

local player = game:GetService("Players").LocalPlayer 
local Hidden = player:WaitForChild("Hidden")
local gui = script.Parent
local Button = script.Parent:WaitForChild("BackFrame").TextButton

Button.Activated:Connect(function()
	if Button.Text == "Mute" then
		Button.Text = "Unmute"
	elseif Button.Text == "Unmute" then
		Button.Text = "Mute"
	end
	if Button.Text == "Unmute" then
		local Children = script.Parent.Parent.Sounds:GetChildren()
		for i, v in pairs(Children) do
			if v:IsA("Sound")then
				v.Volume = 0
			end
		end
	end
	
	if Button.Text == "Mute" then
		local Children = script.Parent.Parent.Sounds:GetChildren()
		for i, v in pairs(Children) do
			if v:IsA("Sound")then
				v.Volume = 1
			end
		end
	end
end)

1 comment

0

You could use v:Stop() and also i think it's because you're using the buttons text and i'm sure it won't update. I never used that type of system so i could be wrong though!

1 answer

Try this?

local sound = script.Parent.Parent:GetChildren()
for i = 1, #sound do
    if sound:IsA ("Sound") then
sound.Volume = 0
end
end

Just wingin it here.

3 comments

0

Still doesn´t work, it keeps telling me that there is an error in line 3

0

can you paste the error please?

1

You’re trying to use :IsA() on the table itself on line 3, so that might be where the error is coming from. Try doing "sound[i]:IsA("Sound")" to get every object.

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