Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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)
0
I'm having the same issue DiamondMiner199 30 — 4y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago

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

0
if this worked, mark this as the answer and thanks :D Xapelize 2658 — 4y
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. Juansirdudefam 24 — 4y
Ad

Answer this question