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

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

Asked by 4 years ago

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)
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! Derzett 51 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

0
Still doesn´t work, it keeps telling me that there is an error in line 3 AndriusTheGreat 140 — 4y
0
can you paste the error please? ReallyUnikatni 68 — 4y
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. User#20279 0 — 4y
Ad

Answer this question