#I'm Creating a Wave System, and I want to check if all clones are Dead before Starting the Next Wave

5 messages · Page 1 of 1 (latest)

stable peak
#

I have a script that basically just clones zombies, and I don't know to check to see if the Zombies are Dead, so I can't have a proper wave system that I want. What should I do?

reef cipher
#

You can track the quantity of enemies spawned using an IntValue, adding 1 to the count for each enemy you clone. Assuming you are using Roblox's standard Humanoid in your zombie, you will know it is dead when the Humanoid.Health property reaches 0. When this happens you can subtract 1 from the IntValue used to track the currently alive Zombies.

Here is a rough idea of what that would look like

-- In your zombie spawning script
ZombieCounter = Instance.new('IntValue')
ZombieCounter.Name = 'Zombies'
ZombieCounter.Parent = game.Workspace

function SpawnZombie()
  ZombieCounter.Value += 1
end


-- In your Zombie's model with a Humanoid
Zombie = script.Parent
ZombieCounter = game.Workspace:FindFirstChild('Zombies')
Humanoid = Zombie:WaitForChild('Humanoid')
Humanoid.Died:Connect(function()
  ZombieCounter.Value -= 1
end)
stable peak
#

k thx fam it worked

amber lavaBOT
#

studio** You are now Level 1! **studio

stable peak
#

a better way to do this actually was in the spawner script, make a folder for the zombies to go to. have the zombie copy parent = workspace.Folder
zombieCopy.Parent = workspace.Enemies