Hello everyone,
I’m making a zombie spawn script and trying to make it spawn a lot of zombies (400-500 at once) for my game but it seems that my method is inefficient as it has a high activity (around 3%-5%) and I want to reduce that as much as possible. Is there another way to spawn them with as low activity as possible?
Code:
local ZombieRig = workspace.ZombieRig
local GrassFolder = workspace.Grass
local ZombieAmount = 200
task.wait(1)
for i = 1 , ZombieAmount do
local Clone = ZombieRig:Clone()
local SpawnNumber = math.random(0,8)
local SpawnLocation = GrassFolder:FindFirstChild("SpawnZ"..SpawnNumber)
local X = 0
Clone.Parent = workspace.Zombies
Clone:PivotTo(SpawnLocation.CFrame)
Clone.Humanoid:MoveTo(GrassFolder:FindFirstChild("X0Z"..SpawnNumber).Position)
Clone.Humanoid.MoveToFinished:Connect(function(reached)
X += 1
print(reached)
if not Clone:FindFirstChild("HumanoidRootPart") then return end
if not GrassFolder:FindFirstChild("X"..X.."Z"..SpawnNumber) then Clone:Destroy() return end
Clone.Humanoid:MoveTo(GrassFolder:FindFirstChild("X"..X.."Z"..SpawnNumber).Position)
end)
task.wait(0.1)
end
Thank you.