I’m making a round system script for my tower defense game and I need help making the script cycle through every wave and spawn zombies:
Here’s the output
Module Script
local module = {}
module.Data = {
["Waves"] = {
["WaveOne"] = {
"Zombie",
"Zombie",
"Zombie" },
["WaveTwo"] = {
"Zombie",
"Zombie",
"Zombie",
"Zombie",
"Zombie" },
["WaveThree"] = {
"Zombie",
"Zombie",
"Zombie",
"Speedy",
"Speedy" }
}
}
return module
Server script
local Zombie = game.ReplicatedStorage.Zombies.Zombie
local Speedy = game.ReplicatedStorage.Zombies.Speedy
local ActiveZombies = game.Workspace.ActiveZombies
local function Spawn(Z)
if Z then
wait(1)
local Clone = Z:Clone()
Clone.Parent = ActiveZombies
end
end
local WaveOne = WaveModule.Data.Waves.WaveOne
local nextSpawn = next(WaveModule.Data.Waves)
while true do
wait(1)
WaveModule.Data.Waves, wave = next(WaveModule.Data["Waves"], wave)
for i, v in pairs(WaveOne)do
wait(1)
Spawn(game.ReplicatedStorage.Zombies[v])
end
end