I keep getting an error saying " [Players.ScriptToon.PlayerGui.MainModule.Toon’s Executor GUI.Frame.Execute.EXE.Server:1: The Parent property of MainModule is locked, current parent: NULL, new parent ServerScriptService]". I know why this error is happening. It’s because I’m trying to parent a destroyed object. It’s a module script by the way. So i re-executed the module using “require” but it acts like it’s still destroyed. Wouldn’t running the “require” function recreate the module script and everything inside? Or should i be doing this a different way? Here is the important code
local children = script:GetChildren()
_G.t = {}
function module.Lua(input)
table.insert(_G.t,script)
for _,c in pairs(children) do
if c then
table.insert(_G.t,c)
end
end
script.Parent.Respawn.OnServerEvent:Connect(function(player)
if player then
player:LoadCharacter()
local delete = _G.t
for i,v in pairs(delete) do
if v then
v:Destroy()
end
end
end
end)