Trouble with clearing all children from folder

For some reason my script here, isnt working.

local timeRemaining = game.StarterGui.Timer.TextLabel.Value.Value

timeRemaining.Changed:Connect(function()
	if timeRemaining == 1 then
		
		local stage1model = game.Workspace.CurrentStages.c1st

		stage1model:ClearAllChildren()
	end
end)

(Path: game, workspace, CurrentStages(folder), c1st(folder), model, part)

Try destroying the children instead of using the :ClearAllChildren() method. Apparently the children get parented to nil instead of actually destroying them.

local function clearAllChildren(parent)
    for i,v in pairs(parent:GetChildren()) do
        v:Destroy()
    end
end

local timeRemaining = game.StarterGui.Timer.TextLabel.Value.Value

timeRemaining.Changed:Connect(function()
	if timeRemaining == 1 then
		
		local stage1model = game.Workspace.CurrentStages.c1st

		clearAllChildren(stage1model)
	end
end)
1 Like