I am trying to make an spawner for my friends Wave survival game and What I am trying to do is get a list of the available zombie spawn points.
function Handler.SpawnZombies()
for ZombieSpawners in pairs(workspace.Map.Model:WaitForChild("spawner")) do -- Line that errores
if zombiesAlive < 1 then
while zombiesAlive < zombieCount do
local zombie = game.ServerStorage.Zombies[currmap.Value][currmap.Value.." Zombie"]:Clone() -- Gets the map name which is stored here after being selected
zombie.Parent = workspace.Map.Zombies
zombie.CFrame.Position = math.random(#ZombieSpawners)
for zombies in pairs(workspace.Map.Zombies:GetDescendants()) do
zombiesAlive += zombies
if zombiesAlive == zombieCount then
break -- If the amount of zombies alive is the same as the limit we break the loop
end
end
end
end
end
end
If your wondering what currmap.Value means then it is what stores the selected maps name. It is used to get the zombies that are designated to the map specifically. That’s all it does!
Map tree:

Spawn is what the player is teleported to (“Spawned”)
However spawner is what the zombies spawn ontop off
1 Like
Take a look. You need to use GetChildren() or GetDescendants() if you’re going to use an object.
for ZombieSpawners in pairs(workspace.Map.Model:WaitForChild("spawner"):GetChildren())
function Handler.SpawnZombies()
for ZombieSpawners in pairs(workspace.Map.Model:WaitForChild("spawner"):GetChildren()) do -- Line that errores
if zombiesAlive < 1 then
while zombiesAlive < zombieCount do
local zombie = game.ServerStorage.Zombies[currmap.Value][currmap.Value.." Zombie"]:Clone() -- Gets the map name which is stored here after being selected
zombie.Parent = workspace.Map.Zombies
zombie.CFrame.Position = math.random(#ZombieSpawners)
for zombies in pairs(workspace.Map.Zombies:GetDescendants()) do
zombiesAlive += zombies
if zombiesAlive == zombieCount then
break -- If the amount of zombies alive is the same as the limit we break the loop
end
end
end
end
end
end
2 Likes
Oh yes that might be it… Ill give it a go, If it works ill mark this as the solution.
2 Likes
Okay so that stopped it from erroring but it doesnt seem to go past that?
for ZombieSpawners in pairs(workspace.Map.Model:WaitForChild("spawner"):GetChildren()) do
print(ZombieSpawners)
the print will not work but it will not parse and error either?
1 Like
Also for loop uses 2 arguments: Index, Value.
for i, ZombieSpawners in pairs(workspace.Map.Model:WaitForChild("spawner"):GetChildren()) do
print(ZombieSpawners)
1 Like
Oh yes, Im pretty tired so this is why ive forgotten about most things youve replied with 
2 Likes
I might as well just put all the spawners into a folder then get the children of that folder then do what ive done after, I feel like that would be easier. Thanks for the help!
2 Likes
I just fixed it, The wait for child was making it error
for ZombieSpawners in pairs(workspace.Map.Model:GetChildren("spawner")) do
print(zombieCount)
Again thanks for the help @Misinformater!
1 Like
ÂżHow are you supposed to fix that with a single argument? By the way, you need to use GetChildren() with the object you want to index its childrens. Example:
for Number, Mob in pairs(workspace.mobHolder:GetChildren()) do
end
2 Likes
I just want the number of spawners there is right now, This function is still being developed so i am still changing stuff. If I used :GetChildren() by its self it would get everything else inside the tree, So I parsed the name of the objects I want to get.
2 Likes
Oh well, you can ease that process by seeing how many childrens are inside Spawner or Model. ÂżRight?
local zombies = #workspace.Map.Model.Spawner:GetChildren()
2 Likes
Got you, Ill keep that in mind for the future. Thanks.
1 Like