Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ClearAllChildren() isn't clearing everything?

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

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);

4 comments

0

I'm curious to know why you semi-colon each line, is it another language or a different way of doing things?

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.

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

0

@Perci; It doesn't cause any syntax errors.

This discussion is preserved as it was. New answers, comments, and votes are closed.