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)
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
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:
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)
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.
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
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.
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.