Ad
Log in to vote
0

I can't get this simple script to work I'm such a noob?

Asked by
0msh 333 Moderation Voter
3 years ago
script.Parent.MouseButton1Down:Connect(function()
    local music = script.Parent.Parent.Parent.Parent.Parent.PlayerScripts.LocalBackgroundMusic:WaitForChild("BGM")
        if music.Volume > 0.7 then
        music.Volume = 0
        script.Parent.Text = "Unmute Music"
        elseif music.Volume < 0.7 then
            music.Volume = 0.7
            script.Parent.Text = "Mute Music"
        end
end)

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
3 years ago

If the volume is 0.7, nothing will happen.

script.Parent.MouseButton1Down:Connect(function()
    local music = script.Parent.Parent.Parent.Parent.Parent.PlayerScripts.LocalBackgroundMusic:WaitForChild("BGM")
        if music.Volume >= 0.7 then
        music.Volume = 0
        script.Parent.Text = "Unmute Music"
        else
            music.Volume = 0.7
            script.Parent.Text = "Mute Music"
        end
end)

This checks whether the volume is bigger than or equal to 0.7, but the original only does stuff when the volume is bigger than 0.7.

Ad

Answer this question