How do I activate a GUI using a Click Detector?

So I’ve been developing a RP Game. I’ve been trying to link a Click Detector to activate a GUI. I want a Car Spawn GUI to appear when a block is clicked.
This is the Current script I have for activating it but it won’t work:

local click = script.Parent.Parent.Parent.Workspace.Spawn:WaitForChild("ClickDetector")
local frame = script.Parent:WaitForChild("CarSpawner")

frame.Visible = true

Could a IFTHEN statement work?


Could you be more specific? More context?
Where are these scripts? Is it a server or local scripts?
Where is the GUI placed?
What actually doesn’t work?

Please do follow the guidelines and this thread does not belong here, it should be in #development-support:scripting-support

As I understand from your question, you are trying to activate a GUI when you click a Part.

	player:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
 Replace ScreenGui with your GUI name.

Do not use a LocalScript for MouseClick event.

Also, please read About the Design Support category.
This thread should be in #development-support:scripting-support.


The Script is a Child to the GUI

1 Like

If you want a GUI to appear when you click a part then you’ll need to use a ClickDetector. This goes under your basepart. To interact with it in your case, you’ll want to use the .MouseClick event. Then you can do what you want to do.

Are you mistaken for something else?

1 Like

Thanks!! It worked! Have a Great day!!

1 Like

This method is fine when you are using a clickdetector as described above, but do not use this in other scripts!
It could yield whole server-scripts if the client does not have the PlayerGui for any reason, or deleted it.

I would recommend using a RemoteEvent that sends the signal to the player to display the UI.


I meant MouseClick instead of MouseButton1Click. My bad.


Also, I’ve been try to Tween the GUI but How do I make it tween Open?

1 Like

And how would I make the Script repeat so that I could close and open over and over again? Right now I can only Open it once and close it.


Here is an example of GUI Tweening:

	Open Position: {0.25, 0},{0.398, 0}
	Close Position: {0.25, 0},{-0.25, 0}

local Frame = script.Parent
local Open  = false
local Debounce = false

function ToggleTween()
	if Open == false and Debounce == false then
		Debounce = true
		Frame:TweenPosition(, 0,0.398, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce,0.75,false)
		Open = true
		Debounce = false
		Open == true and Debounce == false then
			Debounce = true
			Frame:TweenPosition(, 0,-0.25, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce, 0.75, false)
			Open = false
			Debounce = false

-- Now use ToggleTween() to toggle the GUI everytime you want.

while wait(3) do

You can use any other method to toggle it with the ToggleTween() function. The while wait(3) do is to test it. Here is the GUI example:
GUI.rbxm (2.4 KB)

To insert the GUI:

  • Right click on StarterGUI
  • Insert from file
  • Find and select GUI.rbxm and click Open

Can I please remind that spoon feeding code isn’t what these categories are made for. Its intended to support other users into getting to the goal they intend to.


this doesnt work more than one time

1 Like