Mute button not working well

i have music system and mute button, the mute work but if you mute a song and the song is get switched to the next song and you still on mute you cant unmute the song. idk what to do please help.

music system:

local currentSound = workspace:WaitForChild("CurrentMusic")

local songs = {
	6128664089,
	4973416812,
	5682636501,
	139245469,
	5488827562,
	7099121021,
	5663817515,
	5776344796,
	4879369321,
	321224502,
	2963233268,
	5620431199,
	154988586,
	4510835731-- your audio ids here seperated by a comma.
}

while true do
	for i, song in pairs(songs) do
		currentSound.SoundId = "rbxassetid://" .. song

		if (not currentSound.IsLoaded) then
			currentSound.Loaded:Wait()
		end
		currentSound:Play()
		currentSound.Ended:Wait()
	end
end

Mute local script:

local music = workspace:WaitForChild("CurrentMusic")

script.Parent.MouseButton1Click:Connect(function()
	local volumeToSet = music.Volume == .5 and 0 or .5
	music.Volume = volumeToSet
end)

Heres The Solve:

Mute Local script

local music = workspace:WaitForChild("CurrentMusic")

script.Parent.MouseButton1Click:Connect(function()
	local volumeToSet = 0
	music.Volume = volumeToSet
end)

Also if you want to choose randomly between 0.5 and 0 You can do that:

Mute Local Script

local music = workspace:WaitForChild("CurrentMusic")

script.Parent.MouseButton1Click:Connect(function()
	local MuteVolumes = {0.5, 0}
	local volumeToSet = math.random(1, #MuteVolumes)
	music.Volume = volumeToSet
end)

Mute Local Script:
Maybe you could try;

local music = workspace:WaitForChild("CurrentMusic")
local volumeToSet = music.Volume -- considering you can already hear the music first

script.Parent.MouseButton1Click:Connect(function()
	if music.Volume == 0 then
		music.Volume = volumeToSet
	else
		music.Volume == 0
	end
end)

side note: :warning: INCLUDE wait() InSiDe wHiLe tRuE d0 LoOP it worries me… :warning: