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

How do I make a mute music button?

Asked by 4 years ago

I'm trying to add a mute/unmute music button into my game but when i test it, it doesn't work. Here is the script for the music:

local Sound1 = game.Workspace.Sound.Sound1
local Sound2 = game.Workspace.Sound.Sound2
local Sound3 = game.Workspace.Sound.Sound3

while true do
    Sound1:Play()
    Sound1.Ended:Wait()
    wait(2.5)
    Sound2:Play()
    Sound2.Ended:Wait()
    wait(2.5)
    Sound3:Play()
    Sound3.Ended:Wait()
    wait(2.5)
end

And here is the mute music script:

local sound1 = game.Workspace.Sound
local text = script.Parent.TextLabel

script.Parent.MouseButton1Click:Connect(function()

    if sound1.Volume == 0 then

        sound1.Volume = 1
        text.Text = "Music: On"

    else

        sound1.Volume = 0
        text.Text = "Music: Off"

    end
end)

Answer this question