Hello, I am wondering what I could improve for this wave module script. Right now it basically has a table of waves and what enemies to spawn, but the problem is I want to make it so I can skip the wave using a command and have it just do that wave without the previous wave stacking its income gain and then start the next wave twice.
function Waves:roundBonus(amount, waitDelay, wave)
task.wait(waitDelay or 5)
if not gameOver then
local players = #game.Players:GetPlayers()
for i, player in ipairs(game.Players:GetPlayers()) do
if player:FindFirstChild("Cash") then
player.Cash.Value += 100 + (amount / players)
end
end
if self.Wave then
self:NextWave() -- I think that this is the problem
end
end
end
local gameWaves = {
[1] = {
["Easy"] = function()
Zombies:New("BasicZombie", 5, 0.7)
Zombies:New("Necromancer", 1, 1)
self:roundBonus(100, 15)
end,
["Medium"] = function()
Zombies:New("BasicZombie", 7, 0.6)
self:roundBonus(75, 5)
end,
["Hard"] = function()
Zombies:New("BasicZombie", 10, 0.4)
self:roundBonus(50, 2)
end,
["Nightmare"] = function()
Zombies:New("BasicZombie", 14, 0.3)
Zombies:New("SpeedyZombie", 4, 0.5)
self:roundBonus(25, 27)
end,
};
}
function Waves:NextWave()
if self.Wave < 40 and not gameOver then
self.Wave += 1
self.NewWave:FireAllClients(self.Wave);
self.NewWaveBindable:Fire(self.Wave);
gameWaves[self.Wave][self.CurrentDifficulty]()
end
end