I am making a zombie kind of game and I want to be able to detect how many Zombies are in the workspace so I can make it stop spawning them when the amount of zombies is too high. How would I count them?
✓ ANSWER ACCEPTED
How do I count the amount of something in Workspace?
1 answer
✓ Accepted answer
If they are all called "Zombie" then you can count the number of objects in workspace that are called "Zombie"
local zombies=0
for _,v in pairs(workspace:GetChildren())do
if v.Name=="Zombie"then
zombies=zombies+1
end
end
Something better you could do is just have a folder in workspace where you store all of the zombies. Then you can just check #zombiefolder:GetChildren()
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I'm confused as to why this got downvoted?