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

Why is my script not finding the amount of children in a model?

This PART OF A SCRIPT was made to repeat wait until all of the children (zombies) where dead (destroyed/deleted out of the model). I get no errors from this script, but it just doesn't work.

repeat
	wait(5)
until game:GetService("Workspace").Zombies:GetChildren() < 1

I also tried this script:

repeat wait() until game:GetService("Workspace").Zombies:GetChildren() == 0

This one didn't work either. Any help would be appreciated!

1 answer

✓ Accepted answer

The reason it isn't working, is because you are comparing a table with 1.

Most likely what you want to be doing, is comparing the length of the table with 1. This can be done with the # operator before the table.

repeat
    wait(5)
until #game:GetService("Workspace").Zombies:GetChildren() < 1

2 comments

0

Yo, big thanks. You explained everything pretty well. I'll keep this in mind next time.

0

No problem. Hope everything works out.

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