How do you activate a GUI using a clickdetector?

I need help making a GUI pop up by using a clickdetector.

(Ive tried making the GUI pop up using a mousebuttondown function but it doesnt activate the gui)

local ClickDetector = workspace.ClickDetector -- the click detector obj
local GUI = game.Players.LocalPlayer:WaitForChild("PlayerGui").GUI.Frame -- This is just the gui object
--local script:
ClickDetector.MouseClick:Connect(function()
       GUI.Visible = true
       GUI.Active = true
end
--Tip:Ensure that your GUI objects are parented to a screengui and it must be parented to starter gui.
--In addition, this script must be local to the client
1 Like

When working with ClickDetectors, you should be using MouseClick instead of MouseButton1Click. The latter is used for TextButtons.

1 Like

That’s another way to do it.

--//Insert a Part you want the player to click into Workspace,
--//Then insert a ClickDetector and a Script,
--//Then just put your GUI inside the Script.

local ClickD = script.Parent.ClickDetector

function onClick(plr)
  if not plr.PlayerGui:FindFirstChild("YourGuiNameHere") then 
	 local GUI = script.YourGuiNameHere
	 GUI.Parent = plr.PlayerGui		
  end
end

ClickD.MouseClick:Connect(onClick)
4 Likes