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

How to check if a folder is empty?

As the title says, is there a way to check if a folder has nothing in it?

3 comments

0

Get children()

0

getchildren() what

0

I assume he means this "#game.Workspace.Folder:GetChildren()" if the folder is empty it would return zero

1 answer

To add to what I commented...

This would be a use of that

if #game.Workspace.Folder:GetChildren() == 0 then
	print('The Folder is empty')
else
	print('The Folder is not empty')
end

4 comments

0

Did that and it worked, I added an else statement to it where it would return true if the folder is not empty and if it is, it will return false however it still returns false even if the folder has stuff in it.

0

Would say if you are adding something to the folder with code, that the code is run after the item has been added. Also can I see your code? I updated my code to have an else.

0

Add a wait before the else statement, or loop until child exists

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