Question about for loop without delay

Most of the times 3 zombies spawn, but why does sometimes only 2 spawn?

for i = 1, 4 do
    local zombieClone = zombieTemplate:Clone()
    local chosenSpawnpoint = spawnpoints[math.random(0, #spawnpoints)]

    if zombieClone then
        zombieClone.Parent = workspace
        zombieClone.HumanoidRootPart.CFrame = chosenSpawnpoint.CFrame

Try including a wait() in your loop? Also print i I guess

Arrays don’t start from 0 in Lua, they start at 1. Change your math.random to math.random(1, ...)


Apparently, it seems that it does spawns 4 zombies. I didn’t see the 4th one because it was in the same position of another zombie.