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:

01local Sound1 = game.Workspace.Sound.Sound1
02local Sound2 = game.Workspace.Sound.Sound2
03local Sound3 = game.Workspace.Sound.Sound3
04 
05while true do
06    Sound1:Play()
07    Sound1.Ended:Wait()
08    wait(2.5)
09    Sound2:Play()
10    Sound2.Ended:Wait()
11    wait(2.5)
12    Sound3:Play()
13    Sound3.Ended:Wait()
14    wait(2.5)
15end

And here is the mute music script:

01local sound1 = game.Workspace.Sound
02local text = script.Parent.TextLabel
03 
04script.Parent.MouseButton1Click:Connect(function()
05 
06    if sound1.Volume == 0 then
07 
08        sound1.Volume = 1
09        text.Text = "Music: On"
10 
11    else
12 
13        sound1.Volume = 0
14        text.Text = "Music: Off"
15 
16    end
17end)

Answer this question