ClickDetector only being called once

So I was making a game where you click a ClickDetector and a GUI pops up. To my surprise, if you close the GUI, and click the ClickDetector again, the GUI doesn’t pop back up. Here is my code for the ClickDetector:

game.Workspace.ExitDoor.ClickDetector.MouseClick:Connect(function(player)
	script.Parent.Visible = true
end)
2 Likes

How are you making the GUI disappear? I know it seems like a mundane question, but it could be the fact that you’re making it disappear in a way that doesn’t relate to the Visible value being set to false.

You must put this script in ServerScriptService or in the ClickDetector, not in the Gui.

1 Like

Try and make the script inside of ExitDoor

I am setting the Visible value to false to make the GUI disappear.

is there anything in the output?

Nothing in the output, which is strange.

You’d have to put the script inside the door or inside ServerScriptService and then when someone clicks it instead of just doing Gui.Visible = true you have to fire a remote event to the client on a client side script that would simply do Gui.Visible = true. If you don’t add the remote event the script will only fire the GUI to be visible once, and never again if you repeatedly click it.

This is because when you first joins the game, the Server thinks that the GUI Visible is set to false. Then once you click the door, the Server makes the GUI Visible set to true. However, if you exit out of the GUI like pressing an X button to get out or whatever, and attempt to click the door, it won’t work because the Server still believes that the GUI visible property is set to true even though you made it false locally.

3 Likes

Just tried. My new code is:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	player.PlayerGui.MainGUI.NeighborhoodConfirmationFrame.Visible = true
end)

did it work? (30 characterssss)

This won’t work as you cannot control ScreenGui objects from the server, you need to do what @Sb0bster said and use a remote event

Nope, did not work, which is strange.

Just fixed the problem by using Remote Events.

2 Likes