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

Why does this script only work once?

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

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)

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