The script is supposed to regen a model after a certain amount of time. However, the script doesn't work at all. Output didn't give me anything.
Can someone please help me?
Here's the script:
local Playing = game.ServerScriptService.MainGame:WaitForChild("Playing") local children = script.Parent:GetChildren() local Tanks = children:clone() while wait(10) do if Playing.Value == true then children:remove() wait(0.1) Tanks.Parent = script.Parent end end
The problem is probably that you are trying to call remove()
on children
. children
is a table of Instance
s, not an Instance
itself. To remove all Instance
s in children
, use a generic for loop, like so:
local Playing = game.ServerScriptService.MainGame:WaitForChild("Playing") local children = script.Parent:GetChildren() local Tanks = children:clone() while wait(10) do if Playing.Value == true then for i, v in ipairs(children) do v:Destroy() -- Note that remove() is deprecated. end wait(0.1) Tanks.Parent = script.Parent end end
Also, I believe you should put the main game script somewhere like the workspace, since I don't think scripts in the ServerScriptService can interact with the game world, and that is probably the problem you're having in the first place.