Even though I put in precautions, the music still plays even though when the music is off. Why? Am I missing something?
playing = false
local s1 = script.Parent.Parent.song
local s2 = script.Parent.Parent.song2
local s3 = script.Parent.Parent.song3
local s4 = script.Parent.Parent.song4
script.Parent.MouseButton1Down:connect(function()
if playing == false then -- check if audio is playing
playing = true -- allow the script to know if its on or not
script.Parent.Text = "Music: On" -- change the name like you wanted
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
wait(0.5)
s1:Play() -- play all the music
wait(120)
if script.Parent.Text == "Music: Off" then
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
end
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
wait(1)
if script.Parent.Text == "Music: Off" then
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
end
s2:Play()
wait(106.371)
if script.Parent.Text == "Music: Off" then
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
end
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
wait(1)
if script.Parent.Text == "Music: Off" then
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
end
s3:Play()
wait(101)
if script.Parent.Text == "Music: Off" then
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
end
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
wait(1)
if script.Parent.Text == "Music: Off" then
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
end
s4:Play()
wait(76)
if script.Parent.Text == "Music: Off" then
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
end
s4:Stop()
wait(0.1)
script.Parent.Text = "Music: Off"
else -- if audio is playing we want to stop it
playing = false
s1:Stop()
s2:Stop()
s3:Stop()
s4:Stop()
script.Parent.Text = "Music: Off"
end
end)

1 comment
Anyone?