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)
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()
.