ClickDetector to GUI Help

Actually I just created a basic script to do this

Here is how I set it up
image
image

and here is the code in the local script which is inside the UI

game.Workspace.ClickMe.ClickDetector.MouseClick:Connect(function()
	script.Parent.Frame.Visible = not(script.Parent.Frame.Visible)
end)

ClickToShowButton.rbxl (19.9 KB)

It is in a local script. . . ,

I also want to have a X button on the GUI.

Ok, so you would do the same thing but add an XButton
image
image

New Code

game.Workspace.ClickMe.ClickDetector.MouseClick:Connect(function()
	script.Parent.Frame.Visible = not(script.Parent.Frame.Visible)
end)

script.Parent.Frame.XButton.MouseButton1Click:Connect(function()
	script.Parent.Frame.Visible = not(script.Parent.Frame.Visible)
end)

ClickToShowButton.rbxl (21.8 KB)

3 Likes

It worked! Thank you so much! Thank you guys for helping.