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

Why does my gui not re open once I close it for the first time?

I have a gui that opens when I click on a part and closes when I click a text button. It works fine until I try to re-open that gui again and I'm not sure why that happens.

Here is my code to open the gui:

function onClicked(PlayerWhoClicked)
	    PlayerWhoClicked.PlayerGui.ScreenGui.Frame.Visible = true
	end
	 
	script.Parent.ClickDetector.MouseClick:connect(onClicked)

Here is my code to close the gui:

script.Parent.MouseButton1Click:connect(function()
	script.Parent.Parent.Visible = false
end)

1 comment

0

I'm having the same issue

1 answer

Make sure it was a LOCALSCRIPT.

And make the open the gui script's line 2 like this:

PlayerWhoClicked:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true

its bc only localscript accepts PlayerGui event, and the PlayerGui is not in the workspace before running the game, so you need to put WaitForChild().

2 comments

0

if this worked, mark this as the answer and thanks :D

0

This didn't work. The button to close the gui is in a localscript but the other one isn't. When I put it into a localscript it doesn't work anymore.

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