Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ClearAllChildren() isn't clearing everything?

Asked by 9 years ago

I was trying to clear everything in workspace with this

workspace:ClearAllChildren()

and for the most part, it removes 9/10 of the stuff

but then there's some bricks hanging around refusing to be deleted, why is this? Is it possible I could do something about this?

1 answer

Log in to vote
-1
Answered by 9 years ago

Likely what's happening, is it's encountering the Terrain object. ClearAllChildren() calls Remove to all children of the object.

What you could try and do is something along the lines of:

function removeChildren(mod)
for i,v in next, mod:GetChildren() do
if (v.Name:lower():find('terr')==nil) then
v:Destroy();
end;
end;
end;
removeChildren(workspace);
0
I'm curious to know why you semi-colon each line, is it another language or a different way of doing things? Mystdar 352 — 9y
0
It's not needed it Lua, I'm not sure if it would cause a syntax error or not. Same thing with the '' instead of () after children, it may cause an error. Perci1 4988 — 9y
0
Semicolons are a standard part of Lua and are from time to time mandatory. (They really don't belong after the end keyword though) They mark the ends of statements. Many other languages require semicolons and programmers who work with them and Lua often employ the practice in Lua too BlueTaslem 18071 — 9y
0
@Perci; It doesn't cause any syntax errors. KOTwarrior 150 — 9y
Ad

Answer this question