Hey there, saints of the DevForum. I’m having trouble making my zombie defense wave system loop.
local function startWave()
local numOfZombies = 0
local limit = waveConfig.WAVE_CONFIGS[tostring(currentWave)]["SpawnCap"]
while not (numOfZombies == limit) do
spawnWaveZombies(currentWave)
numOfZombies += 1
print(numOfZombies)
end
end
Start Wave function
local function endWave()
endWaveEvent:FireAllClients()
currentWave += 1
print(currentWave)
return currentWave
end
End Wave function
local function gameProgression()
task.wait(waveConfig.INTERMISSION_TIME)
startWave()
while task.wait(1) do
if #workspace.Zombies:GetChildren() == 0 then -- This basically detects if all zombies are dead.
endWave()
end
break
else
end
end
end
gameProgression()
makeshift game progression function which I’m not very fond of.
Keep in mind that I have left out some unrelated code snippets.
Now, everything in the code samples works, but I’m not sure how to make a function loop so that after the endWave() function gets fired, the startWave() function automatically fires after.