So I want a certain Gui, with a script in it, to reset to it's original state. (So the script resets, and all the texts and frames are back in the original position) To do this I came up with the following script. It works once, but then it gives the following error.
ERROR: The Parent property of BackGround is locked, current parent: NULL, new parent EndGui
I know that the error is caused because I try to clone the thing that I just destroyed, but my intention is to clone the Gui as it was in the beginning of the game, when nothing changed yet. Is there any way I can do this?
script:
local BackGround = script.Parent:WaitForChild("BackGround") local CloneBackGround = BackGround:Clone() local NetCodeValues = game.Workspace:WaitForChild("NetCodeValues") local Ending = NetCodeValues:WaitForChild("Ending") Ending.Changed:connect(function(Value) if Value then script.Parent.BackGround.EndLocalScript.DestroyValue.Changed:connect(function(Value) if Value then script.Parent.BackGround:Destroy() CloneBackGround.Parent = script.Parent elseif not Value then BackGround = script.Parent:WaitForChild("BackGround") CloneBackGround = BackGround:Clone() end end) end end)