Click a part for GUI to become visible

Pretty simple, but I can’t figure out how to use a script to make a gui visible from it being invisible, and I want it to be like you click a part and it appears, any help?

1 Like

you should use clickdetector and put a localscript in it.

just do this :

local click = script.Parent.ClickDetector

click.MouseClick:Connect(function()
	game.Players.LocalPlayer.PlayerGui.GuiNameHere.FrameNameHere.Visible = true
end)

or something like that I don’t have studio open so sorry abt that.

Insert a ClickDetector inside a part and then insert a Script inside the ClickDetector - after that, insert the GUI you want to be shown inside the Script and type this in the script:

script.Parent.MouseClick:Connect(function(p)
local gui = script['GUI Name']:Clone()
gui.Parent = p.PlayerGui
end)
1 Like

Make this a LocalScript and put it either inside game.StarterPlayer.StarterPlayerScripts, game.StarterGui or game.StarterPack, note it can be inside a child under one of either named parents.

local LocalPlayer = game:GetService("Players").LocalPlayer
local ScreenGui = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("OnClickGui") -- ScreenGui called OnClickGui inside StarterGui

local Part = workspace:WaitForChild("ClickPart") -- Part inside workspace called ClickDet
local ClickDet = Part:WaitForChild("ClickDetector") -- ClickDetector inside Part called ClickDetector

ScreenGui.Enabled = false -- please set this before starting

ClickDet.MouseButton1Down:Connect(function() -- On click
   ScreenGui.Enabled = not ScreenGui.Enabled -- switch on/off
end)
1 Like

Lol thanks for correcting me in the MouseClick part. Since I did not have studio open I forgot what it was for a clickdetector.

1 Like

I assume the script should be local?

Correct, if you put the script directly inside of the ScreenGui you can just remove the LocalPlayer variable and replace the value of ScreenGui with script.Parent.

I am expecting workspace to look like so:
image
and StarterGui somewhat like so:
image

If you have another name for either the ScreenGui, Part or ClickDetector, then please feel free to change the name inside of the script.

2 Likes