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

How to check if a folder is empty?

Asked by 5 years ago

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

0
Get children() DinozCreates 1070 — 5y
0
getchildren() what ShiforRBLX 5 — 5y
0
I assume he means this "#game.Workspace.Folder:GetChildren()" if the folder is empty it would return zero ForeverBrown 356 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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
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. ShiforRBLX 5 — 5y
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. ForeverBrown 356 — 5y
0
Add a wait before the else statement, or loop until child exists DinozCreates 1070 — 5y
Ad

Answer this question