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

Checking if my folder is empty or something is inside?

Asked by 7 years ago

i just need a little code to check if my "GegnerStorage" folder is empty.

i tried this but it didnt work.

if game.workspace.GegnerStorage == nil then 
        status.Value = "You Won!"
        break
0
Try #game.workspace.GegnerStorage:GetChildren() == 0 then shakran 23 — 7y

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
7 years ago

Well if the folder is empty, it would still exist. You just need to check the number of children it has inside (0 if it's empty).

GetChildren returns a list of all the children, and the # operator will tell you the number of items in a list. So you can just check if #GegnerStorage:GetChildren() equals 0.

0
Thanks very much! works now Paintertable 171 — 7y
Ad

Answer this question