Help me fix a bug

Hi, I am making a music mute system but only sometimes the music plays even it is muted; Here’s the code:

local Button = script.Parent
local music = script.Parent.Parent.Parent.Parent.Sound

local sound = script.Parent["Game SFX | Click Sound Effect"]

Button.MouseButton1Click:Connect(function()
    sound:Play()
    if music.IsPlaying then
        music.Playing = false
        music:Pause()
		script.Parent.Image = "rbxassetid://5816997299"
    else
        music.Playing = true
		music:Resume() 
		script.Parent.Image = "rbxassetid://5816996037"
    end
end)
1 Like

is there any output if there is

Firstly, I reccomend using MouseButton1Up, and two; send a picture of your output.