Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make when a part is clicked with a ClickDetector open a GUI?

So i want to use a ClickDetector for when a part (the ClickDetector's parent) is clicked, make a Gui pop up/appear. So far this is what i have: (in a LocalScript)

script.Parent.ClickDetector.MouseClick:connect(function()
	if workspace.Part.Transparency == 0 then
		for i,v in pairs(game.Players:GetPlayers()) do
			v.PlayerGui.Gui.Menu.Visible = true
			print("Gui opened.")
		end
	end 
end)

That's what i wrote, and it didn't pop up! Can you tell me why plz? Thx

1 answer

I don't think that works in a Local script. I did this script in a Normal script and it works:

script.Parent.ClickDetector.MouseClick:connect(function(Player)
	Player.PlayerGui.Gui.Menu.Visible = true
	print("Gui opened.")
end)

Let me know if that worked

1 comment

0

You shouldn't be running the function through the ClickDetector, since it is just so there is a cursor and the Mouseclick fires when it's clicked. Also, I recommend using MouseButton1Click instead.

This discussion is preserved as it was. New answers, comments, and votes are closed.