TextButton not working

local Songs = game.Workspace.Songs:GetChildren()
local MuteButton = game.StarterGui.MuteButton.SpectateButton.Spectate
local MuteText = game.StarterGui.MuteButton.SpectateButton.Spectate
MuteButton.MouseButton1Click:Connect(function()
	print("what")
	if MuteText.Text == "Mute" then
		for i = 1, #Songs do
			local Song = Songs[i]
			Song.Volume = 0
		end
		MuteText.Text = "Unmute"
	else
		for i = 1, #Songs do
			local Song = Songs[i]
			Song.Volume = 0.5
		end
		MuteText.Text = "Mute"
	end
end)

while true do
	for i = 1, #Songs do
		local Song = Songs[i]
		Song:Play()
		wait(Song.TimeLength)
		Song:Stop()
	end
end

I’m trying to make a music player and a gui to mute the audio. The problem is that the gui isn’t muting the audio when clicked on. I tried checking the properties of the gui to see if it was inactive, but everything was good.

All children of StarterGui will replicate to Player.PlayerGui
To solve your problem, could you show the explorer tab please?

Do you want to see the PlayerGui or the entire explorer?

Show me the StarterGui

screenshot

Could you show me the Workspace as well?

Show me the Songs folder.

There is only one sound in that folder.

Will you use more songs within that folder?

Yeah, I will include more later.

I recommend your sounds within a SoundGroup and put that within the SoundService. Like this:

soound

Ok, so I just put the sounds in a soundgroup located in the soundservice, and I change my script so that you get the children from the soundgroup.

Put this in the local script:

local Songs = game:GetService("SoundService"):WaitForChild("SoundGroup")
local MuteButton = script.Parent
local MuteText = MuteButton.Text
MuteButton.MouseButton1Click:Connect(function()
	print("what")
	if MuteText.Text == "Mute" then
		Songs.Volume = 0
		MuteText.Text = "Unmute"
	else
		Songs.Volume = 0.5
		MuteText.Text = "Mute"
	end
end)

And set Looped value to true to all GroupSound's children

(I just edited it)

Did you forget to add the Play() function? Edit: It still doesn’t work for some reason when I changed the property of the sound to be playing and looped. I’m starting to believe it is something to do with the gui.

Oh, so. Set Playing value to true to all GroupSound's children

I did already but it still doesn’t work.

Is the sound playing when you test?

Yeah, it is playing the sound.

So, is there a problem with the script?