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

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

Asked by 10 years ago

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?

0
You destroyed the original, so you need to name the clone, then destroy what the clone (from it's name), not the original. GoldenPhysics 474 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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.'

Ad

Answer this question