Help with GUI button not working

So I made a script for a button that disappears when you press it but it doesn’t disappear

This is the code:

local PlayButton = script.Parent.PlayButton

PlayButton.MouseButtonClick:Connect(function()
PlayButton.Visible = false
end)
Can somebody help me fix this problem?

MouseButton1Click not MouseButtonClick. IF that doesn’t work, a few extra questions

Is PlayButton a TextButton or an ImageButton? If not, then they must be for MouseButton1Click to work

Script must be a Localscript, not a regular script

1 Like

If this is a server script, the changes won’t be replicated to the client

Oooooh no I just forgot the 1 in the article but thanks I forgot to put the script in localscript

1 Like

Well it’s an imagebutton I did put it in a local script this time but it still doesn’t work

Any errors? May I see both the code and where the imagebutton is located in the explorer?

Sorry for bad quality

Isn’t it

MouseButton1Click

instead of

MouseButtonClick

What’s your code right now? I think your issue, if the script is in the PlayButton, is that you’re doing script.Parent.PlayButton instead of script.Parent

1 Like

I know it’s just a mistake in the article

Ah okay then I didn’t see that my mistake.

Thanks it worked! 30 (characters)

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

Is it a local script? It usually doesn’t work if it is a local script.

Tip: I see you have multiple scripts for each button. You could put everything in one script.

-- Example Script
local Button1 = script.Parent.Button1
local Button2 = script.Parent.Button2

Button1.MouseButton1Click:Connect(function()
print("Button 1 Clicked")
end)

Button2.MouseButton1Click:Connect(function()
print("Button 2 Clicked")
game.Players.LocalPlayer.Character.Humanoid.Health = 100 -- Heal the player
end)
1 Like