How To Make Zombie Spawn Waving System?

im trying to make like, waving spawn zombie example
wave1 will spawn 5 normal and 2 heavy
wave2 and so on

Heres a simple script to help you understand.

local Waves = {
	[1] = {
		Count = 2,
		Heavy = 3
	},
	

	[2] = {
		Count = 25,
		Heavy = 1
	},
}

for Wave, Data in pairs(Waves) do
	for i = 1, Data.Count do
		-- spawn zombie.
	end
 wait(wave length)
end

You can create a dictionary and loop through the table.

whats the difference between count value and heavy value ?

Count value is x amount of zombies spawned during the wave, heavy value is x amount of heavy zombies you want to spawn?

oh so like count value is the max value ?, if it reach it will stop and fire a new wave ?

Yes, max amount of zombies allowed to spawn during the round.
Loops (roblox.com)

Can you explain what you mean hit? If your talking about a zombie being damaged, you will need to turn this into an fucntion.

oh wow, so that was the max value. the heavy value is where the zombie will spawn
like every loop the script will spawn x value of heave until it reach max spawn limit ?

Yes it will keep spawning until it reaches max amount.

and last quest, how do the script changes for [1] to [2] ?
i dont see any system that change the data

What do you mean? To answer one of your previous questions if your trying to start another wave if an zombie is damaged you can use functions for that.

local Waves = {
	[1] = {
		Count = 2,
		Heavy = 3
	},
	

	[2] = {
		Count = 25,
		Heavy = 1
	},
}

local CurrentWave = 0

local function StartWave()
	if CurrentWave == 2 then
		-- Start down to 1 again.
		CurrentWave = 1
	else
		CurrentWave += 1
	end
	
	local Data = Waves[CurrentWave]
	
	for i = 1, Data.Count do
		-- Spawn Zombie
		zombie.Humanoid.HealthChanged:Connect(function()
			StartWave()
		end)
		
		wait(cooldown between each zombie spawning...)
	end
	
	-- rest of your script
end

StartWave()
1 Like

I think your asking how does it loop from 1 to 2, it uses Loops.

More information here: Introduction to Scripting | Roblox Creator Documentation

yes this will help me a lot, sorry for my english lol. didnt good at XD.
so if you want to clone the specific zombie ?

like heave,normal,fast etc?

You index the instance where its at for example ServerStorage and use :Clone()

More information on how to clone instances at: Instance:Clone (roblox.com)

wow, thx for the help. Sorry Again For My English

You can let the zombies spawn at a dedicated location using SetPrimaryPartCFrame.

local Waves = {
	[1] = {
		Count = 2,
		Heavy = 3,
	},
	

	[2] = {
		Count = 25,
		Heavy = 1
	},
}

local CurrentWave = 0
local Spawns = workspace.Spawn:GetChildren()

local function StartWave()
	if CurrentWave == 2 then
		-- Start down to 1 again.
		CurrentWave = 1
	else
		CurrentWave += 1
	end
	
	local Data = Waves[CurrentWave]
	
	for i = 1, Data.Count do
		-- Spawn Zombie
		zombie.Parent = workspace
		local pad = Spawns[math.random(1, #Spawns)]
		zombie:SetPrimaryPartCFrame(pad.CFrame)
		zombie.Humanoid.HealthChanged:Connect(function()
			StartWave()
		end)
		
		wait(cooldown between each zombie spawning...)
	end
	
	-- rest of your script
end

StartWave()

image

If this helped you solve this you can mark this a solution.

1 Like

so for example

local data = {
[1] = {
         Count = 10
         Heavy = 3
         Normal =  1
}
[2] = {

}

}

How do i change the clone from heavy to normal?

Please remember to read the rules before making a topic

That being said. If you’re having trouble with planning a system, you should try this.

  1. Define what you want to achieve:
    – Create a Zombie Wave System
  2. What are waves?
    – Rounds that expire when all the zombies are dead
  3. How do waves start?
    – Create 50 zombies
  4. How do waves end?
    – When all zombies’s health is 0
  5. What happens after the wave?
    – wait some time
  6. How many waves should there be?
    – etc…

If you learn to break down your ideas into smaller pieces, you will find it much easier to focus on what to code.
Don’t be afraid of trying things, nor of remaking systems like this from the start again if you have a better idea. That is called refactoring.

  1. Design
  2. Prototype
  3. Improve
  4. Repeat
2 Likes

oh thx for the warning, yea from the title i wrote “i can do it with for i,v, but idk what next”
so the point is i dont ask ppl to wrote me all the script. just tell me like @vq9o did, how the script run and how the script loops. lastly im kinda new with roblox studio so, there was rules that i didnt see or did it

1 Like

after almost a year. i finnaly know how to make one. If someone see this, thx for the help.

1 Like