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

Why does this script only work once?

Asked by
Danfly 5
10 years ago

I have this gui script after I open it and close it, when I try to open it the 2nd time it didn't work. What do I need to do to fix it?

1function boop(Player)
2    if not Player.PlayerGui:FindFirstChild("Gui") then
3        local gui = script.Gui:clone()
4        gui.Parent = Player.PlayerGui
5        gui.LocalScript.Disabled = false
6    end
7end
8script.Parent.ClickDetector.MouseClick:connect(boop)

1 answer

Log in to vote
0
Answered by 10 years ago

Question, does the local script when you close that GUI remove the whole GUI from the PlayerGui or does it make the Frames Visible false? If so then simply make it were you add:

01function boop(Player)
02    if not Player.PlayerGui:FindFirstChild("Gui") then
03        local gui = script.Gui:clone()
04        gui.Parent = Player.PlayerGui
05        gui.LocalScript.Disabled = false
06elseif Player.PlayerGui:FindFirstChild("Gui") then
07Player.PlayerGui:FindFirstChild("Gui").LocalScript.Disabled = true
08Player.PlayerGui:FindFirstChild("Gui").LocalScript.Disabled = false
09Player.PlayerGui:FindFirstChild("Gui").*NAME OF FRAME*.Visible = true
10    end
11end
12script.Parent.ClickDetector.MouseClick:connect(boop)
Ad

Answer this question