Hello guys my music gui don't work

Hello ! i made a script so that when a player joins he’ll get music and he can deactivate or reactivate but the problem is that it doesn’t work so if someone can help me that would be great!

here is the script

local music = game.Workspace.Sounds.Dion
local button = script.Parent.Mute
playing = true

script.Parent.MouseButton1Click:Connect(function()
if playing == true then
music.Playing = false
button.Text = “:mute:
playing = false
else
music.Playing = true
button.Text = “:loud_sound:
playing = true
end
end)

ofc My sound name is “Dion” and i put the script on local script

2 Likes

No where in the script do I see you playing the sound.

1 Like

Wait so is script.Parent.Mute supposed to do the toggling?

If so, change script.Parent.MouseButton1Click to script.Parent.Mute.MouseButton1Click, or alternatively, button.MouseButton1Click

local music = game.Workspace.Sounds.Dion
local button = script.Parent.Mute
playing = true

button.MouseButton1Click:Connect(function()
    if playing == true then
        music.Playing = false
        button.Text = “:mute:”
        playing = false
    else
        music.Playing = true
        button.Text = “:loud_sound:”
        playing = true
     end
end)
3 Likes

Is the event firing? Put print(“test”) inside of the event and see if it fires

1 Like

Adding onto this, made it a little more efficient, and I’m sure you can’t modify the Playing property directly.

local music = game.Workspace.Sounds.Dion
local button = script.Parent.Mute
playing = true

button.MouseButton1Click:Connect(function()
	if playing then
		music:Pause()
		button.Text = “:mute:”
	else
		music:Play()
		button.Text = “:loud_sound:”
	end
	playing = not playing
end)
2 Likes

I don’t know if I did it wrong but it still doesn’t work

1 Like

This should work just fine. It’s a local script, and the button is a TextButton, and it’s referenced properly, right? Can you show us the errors, if any?

1 Like

I recommend putting the Sound in SoundService and making it play from there.

“local music = game:GetService(“SoundService”):WaitForChild(”[your music]“)”
Hopefully this helps :slight_smile:

1 Like