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

After the first use, this GUI stops destroying but continues to clone. Can it be fixed?

This GUI is needed to destroy a GUI "NewGame" and clone it form lighting, placing it back in the Localplayers GUI. "NewGame" can freeze up form time to time and I hope this will simulate a refresh.

However after the first use, which works as intended, the second time its clicked the cloned "NewGame" is not destroyed and a second clone form lighting is placed in the playerGui.

here is the script that is in the GUI that is simulating a refresh to "NewGame"

local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("NewGame")

script.Parent.MouseButton1Click:connect(function()
Gui:Destroy()
wait(1)
Game.Lighting.NewGame:Clone().Parent = game.Players.LocalPlayer.PlayerGui
end)

How can I get "NewGame" to be destroyed on every click?

1 comment

0

You destroyed the original, so you need to name the clone, then destroy what the clone (from it's name), not the original.

1 answer

You need to index your local Gui inside your function. Otherwise it is only getting it when the script first runs, and thus doesn't have the updated 'GUI.'

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