How would I detect if there is no more Children?

I’m trying to make it so that when a Folder has no more Children then it would destroy itself.

Any help will be appreciated!

if #(folder:GetChildren()) == 0 then
	folder:Destroy()
end
3 Likes

You can do it without parentheses too:

if #folder:GetChildren() == 0 then
	folder:Destroy()
end

Why add extra memory if it literally gives you more to type

Wow that’s so simple, thank you!

It doesn’t use more memory to have extra parentheses, I just wanted to make it clear that # operates on the result of GetChildren() and not on folder.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.