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

How do I count the amount of something in Workspace?

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?

1 comment

0

I'm confused as to why this got downvoted?

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.