ClickDetector to GUI Help

  1. What do you want to achieve? I want to have a GUI pop up when you click a part.

  2. What is the issue? I got it to work but it only works once. For example, if I click the part once it works. I close out of the gui and click it a second time but it doesn’t work the second time.

  3. What solutions have you tried so far? I have tried looking on the dev forum, and multiple videos but no luck.

Here is some details. I put a click detector in a part, and a script in the click detector. Here is the code I used.

player:WaitForChild(“PlayerGui”).DoorGUI.DoorSystem.Visible = true

Like I said above, it works only once, but when you close out of the gui and try it again, it doesn’t work. Thanks for reading, btw! :slight_smile:

p:WaitForChild(“PlayerGui”).DoorGUI.DoorSystem.Visible = true

script.Parent.Parent.Visible = false

1 Like

Did you check if your exit button makes it visible or deletes the GUI

1 Like

When you click the x button it makes visible = false

dont waitforchild just do if p.PlayerGui then <code here> end

1 Like

if that doesnt work do if p:FindFirstChild("PlayerGui") then <codehere> end

1 Like

@romeanyguy10 Welcome to the forums!

The script you are using can we improved, this is a local script inside the x button:

local Part = #The part with the ClickDetector 
local ClickDetector = Part.ClickDetector

local GUI = #the GUI to become visible and invisible
local XButton = script.Parent

    GUI.Visible = true

    GUI.Visible = false

@iSyriux You should utilize waitforchild because there is no guarantee that the playergui has been loaded yet. Please be sure before tou assume things.

It didn’t work when I tried to test. I tried to write “ClickDetector.Clicked” but when I write “Clicked,” it isn’t identifying anything.

1 Like

Oops, that was a typo, it’s MouseClick, not Clicked.

It didn’t work. Again when I typed MouseClick it didn’t identify anything. There were no red lines which was good but when I typed MouseClick it didn’t identify anything. Thanks for helping btw! :smiley:

Did you fill in the missing variables?

Yep I filled them in correctly.

Can you paste your GUI variable for me?

frame = game.StarterGUI.DoorGUI.DoorSystem

Okay! Let me try it real quick…

Just to make things clear. A local script inside of the x button?

I have the same problem, I only got a GUI to pop up once but I could not open it again after closing it.

I hope you find the answear to fix it though! :smiley:

Correct. Also, replace the frame variable with this:

frame = game.Players.LocalPlayer:WaitForChild(“PlayerGui”).DoorGUI.DoorSystem

Didn’t work. When I was typing frame.Visible, it would not even identify frame. Also, when I was writing MouseClick, it didn’t identify that either. Lastly in the output I saw this “- Infinite yield possible on ‘Players.romeanyguy10:WaitForChild(“PlayerGUI”)’” - Could that mean something?

Is the code in a server script or local script?

Server scripts look like the normal paper, local scripts have the little player icon on them