Why does it not delete all of it?

Hi! Hope your having a good day!

I am trying to delete all of the blocks that are in this folder, however it only deletes like 90% of it. The rest don’t get deleted and I do not know why. There are no errors, it just doesn’t delete! If someone could figure out why this is happening, that would be greatly appreciated!

Thanks! :snowflake:

Here is my code:

--Server script in SSS (ServerScriptService)
Status.Value = "End of game!"
task.wait(2)

for i,player in pairs(game.Players:GetPlayers()) do
	local charac = player.Character

	if not charac then
		print("Player does not have character!")
	elseif charac then
		if charac:FindFirstChild("GameTag") then
			charac.GameTag:Destroy()
			player:LoadCharacter()
		end
	end
end
for i,v in pairs(workspace.StepsFolder:GetChildren()) do
	if v.Name == "Step" then
		v:Destroy()
	end
end
ClonedMap:Destroy()
workspace.Lobby.Construction.SurfaceGui.TextLabel.Text = "0"
workspace.Lobby.Radioactive.SurfaceGui.TextLabel.Text = "0"
workspace.Lobby.City.SurfaceGui.TextLabel.Text = "0"
Timer.Value = 180


task.wait(3)
--END OF GAME ENDING

Along with a picture before and after deletion;
Before:
image

After:

In the game:

The purple blocks are the steps by the way.

instead of that, try this:

workspace.StepsFolder:ClearAllChildren()

That still does not work sadly.

local StepsFolder = game.Workspace.StepsFolder

    for _, v in pairs(StepsFolder:GetChildren()) do
         if v:isA("BasePart") then
    v:Destroy()
    end
end

I think you’re missing

game.Workspace

No it works. Workspace is just a shortened version of game.Workspace. It is easier and honestly to me it looks nicer. Whichever one you choose, it does the same thing.

Also your previous post does not work either :((

Maybe run it twice? Maybe that could help?

You mentioned that it’s deleting some Instances, but not all of them. I’m curious whether you’re checking the explorer from the client, or from the sever. Is it possible that some of these parts are being generated client side, and so they’re not being removed because they don’t actually exist on the server (where this destruction code is running)?

That could be possible, because theres another scripter working on the game w/ me so he may have done something. This destruction code is a server script in ServerScriptService