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?

function boop(Player)
    if not Player.PlayerGui:FindFirstChild("Gui") then
        local gui = script.Gui:clone()
        gui.Parent = Player.PlayerGui
        gui.LocalScript.Disabled = false
    end
end
script.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:

function boop(Player)
    if not Player.PlayerGui:FindFirstChild("Gui") then
        local gui = script.Gui:clone()
        gui.Parent = Player.PlayerGui
        gui.LocalScript.Disabled = false
elseif Player.PlayerGui:FindFirstChild("Gui") then
Player.PlayerGui:FindFirstChild("Gui").LocalScript.Disabled = true
Player.PlayerGui:FindFirstChild("Gui").LocalScript.Disabled = false
Player.PlayerGui:FindFirstChild("Gui").*NAME OF FRAME*.Visible = true
    end
end
script.Parent.ClickDetector.MouseClick:connect(boop)
Ad

Answer this question