How do I make my wave system progressively harder?

So I have a wave game and I have a super easy enemy for the first couple waves and a slightly more difficult one for the medium waves and i was wondering how I would make it so if its more into the waves like wave 3 or 5 the medium enemys start to spawn and more waves they spawn even more

heres my current code for just one enemy…


local orphans = game.ServerStorage.orphans
local spawnFolder = workspace.orphanSpawns
local orphanFolder = workspace.orphanFolder

local inttime = 10
local waveamount = 8

local waveInProgress = false


game["Run Service"].Heartbeat:Connect(function()
	if not waveInProgress then
	

		waveInProgress = true
		

	
		task.wait(2)
		
		game.ReplicatedStorage.status.Value = "wave starting..." .. waveamount.. " orphans"
		
		print(waveamount)
		task.wait(2)
		
		game.ReplicatedStorage.status.Value = "wave: "..#orphanFolder:GetChildren().. " orphans remaining"

		for i = 1, waveamount do
			
			task.wait(.25)



			if #orphanFolder:GetChildren() <= waveamount  then
				
				game.ReplicatedStorage.status.Value = "wave: "..#orphanFolder:GetChildren().. " orphans remaining"

				orphanFolder.ChildRemoved:Connect(function()
					game.ReplicatedStorage.status.Value = "wave: "..#orphanFolder:GetChildren().. " orphans remaining"
				end)
				
				local babyorphan = orphans["baby orphan"]:Clone()
				babyorphan.Parent = orphanFolder
				local orphanSpawn = spawnFolder:GetChildren()[math.random(1, #spawnFolder:GetChildren())]
				babyorphan.HumanoidRootPart.CFrame = orphanSpawn.CFrame
			else
				break
			end
		end
		game.ReplicatedStorage.status.Value = "wave: "..#orphanFolder:GetChildren().. " orphans remaining"

		

		while #orphanFolder:GetChildren() > 0 do
			task.wait(1)
		end

		game.ReplicatedStorage.status.Value = "wave ending..."

		task.wait(1)
		waveamount = waveamount + 2
		game.ReplicatedStorage.status.Value = "intermission.."
		task.wait(inttime)

		waveInProgress = false
	end
end)
4 Likes

I’m assuming the waveamount variable is the current wave. If not, you would want to create a variable for that and add one wave count each time a wave ends.

if 3 < wave_count < 5 then
      --spawn hard enemies
elseif 5 < wave_count < 8 then
      --spawn harder enemies
end
2 Likes

how would i do this using math… so there can be like a bunch of waves and i dont have to add a if statement for each one?

1 Like

Do you mean to automatically calculate the easy, medium, and hard difficulties, regardless of how many rounds there actually are?

If so, it would be something like this:

local rounds = 100
local medium = math.round(rounds/3)
local hard = medium*2

print(medium,hard)
1 Like

i want it to be like dyanmic so increasingly more difficult enemies spawn

1 Like

The script I provided was just to provide you with a general understanding with what you need to do. If you want a bunch of different waves and you want it to be more efficient, you could try something like this with tables:

local wave_types = {
	["Easy"] = {
		[1] = 1,
		[2] = 3,
		[3] = 5,
	},
	["Medium"] = {
		[1] = 8,
		[2] = 15,
		[3] = 25,
	},
	["Hard"] = {
		[1] = 30,
		[2] = 50,
		[3] = 80
	}
}

1 Like

how would I implement this into my script? and what happens if the player reaches over level 80?

1 Like

If you’re wanting more enemies to spawn or have higher health or damage values, just multiply that by the current round, something like:

local currentRound = 50
local round1Enemies = 20
local enemyRoundMultiplier = 1.1

local enemiesThisRound = math.ceil(currentRound * round1Enemies * enemyRoundMultiplier)
1 Like

no im talking like different variants so… lets say we have like a noraml zombie and a fast zombie at first i want normal zombies but later down the line eventually more and more fast zombies will spawn… so on and so forth with over variants of zombies.

1 Like

the next zombie being more difficult than the last

1 Like

That makes more repetitive waves with no variety of zombies. I’m pretty sure he is trying to get different zombies to spawn each wave.

well after a certain amount of waves add more variants of zombies eventually having no normal zombies and just harder zombies adding a challenging gameplay

1 Like

The first thing I recommend is to have a spawn function, which has the attributes type(of zombie) and amount.

1 Like

alright then how would i calculate when i spawn harder more difficult zombies?

1 Like

I’m not really sure what you’re asking for here.

That will automatically calculate all 3 difficulties no matter how many rounds there are. Just check to see if the current round is greater than a given difficulty and spawn the corresponding enemies. You can add more difficulties if you want to limit what kinds of zombies spawn there.

If you’re wanting to do this purely with math and no actual set difficulties, you can do something similar to the number of zombies, but have the amounts increase or decrease based on the round. So easy zombies would be more common early and less common later on, and harder zombies would be the reverse of that.

1 Like

hmmm. how would i accomplish this?

1 Like

So if you had a spawnMob function, you could do something like this:

local waves_types = {
	[1] = spawnMob("Zombie", 3),
	[2] = {spawnMob("Zombie", 5), spawnMob("Fast", 1)}
}
1 Like

If the wave amount is for example 1-5, it will use wave_type 1. The spawnMob function can multiply the amount of zombies it spawns by the wave amount.
If the wave amount is for example 6-10, it can use wave_type 2, which adds in different zombies.

1 Like

Here’s an example of this(It is just printing out how much it will spawn):

local current_wave = 2

function spawnMob(typeOfZombie, amount)
	local final_amount = math.round(amount*1.5)
	return("Spawned "..final_amount.." of " .. typeOfZombie)
end

local waves_types = {
	[1] = spawnMob("Zombie", 3),
	[2] = {spawnMob("Zombie", 5), spawnMob("Fast", 1)}
	
	
}

print(waves_types[1])
print(waves_types[2])
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.