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

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
1
Answered by
amanda 1059 Moderation Voter
6 years ago

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
0
Yo, big thanks. You explained everything pretty well. I'll keep this in mind next time. kittonlover101 201 — 6y
0
No problem. Hope everything works out. amanda 1059 — 6y
Ad

Answer this question