Need help with repeat function and loops

Basically, I have a loop which starts with an intermission of 15 seconds, then starts the round, starts the first wave, then repeats wait(1) until no people are left on the human team.

while true do
	intermission(INTERMISSION_TIME) -- teleports players to lobby and waits INTERMISSION_TIME
	print("Round starting!")
	

	start() -- teleports players to map
	wave(1) --starts first wave
	
	repeat 
		task.wait(1)
	until #game.Teams.Humans:GetPlayers() == 0 and #game.Teams.Zombies:GetPlayers() > 0 --wait until every player is on the zombie team
end

However, without breaking the loop, or running it again, I want to wait a certain time (for example 1 minute) until starting the second wave. (wave function)

1 Like

you want to wait for some time before starting the next wave maybe make it wait() after repeat function. Like this

while true do
	intermission(INTERMISSION_TIME) -- teleports players to lobby and waits INTERMISSION_TIME
	print("Round starting!")
	

	start() -- teleports players to map
	wave(1) --starts first wave
	
	repeat 
		task.wait(1)
	until #game.Teams.Humans:GetPlayers() == 0 and #game.Teams.Zombies:GetPlayers() > 0 --wait until every player is on the zombie team

wait(60)
end

1 Like

Maybe do something like:

local currentWave = 1

while true do
	intermission(INTERMISSION_TIME) -- teleports players to lobby and waits INTERMISSION_TIME
	print("Wave "..currentWave.." starting!")
	start() -- teleports players to map
	wave(currentWave) --starts current wave
	repeat task.wait(1)
	until #game.Teams.Humans:GetPlayers() == 0 and #game.Teams.Zombies:GetPlayers() > 0 or #game.Teams.Zombies:GetPlayers() == 0
    if #game.Teams.Zombies:GetPlayers() == 0 then
        currentWave = currentWave +1
        else
        currentWave = 1
    end
end
1 Like

Is there a way to use the repeat function for for example 60 seconds?
What I mean:

repeat
     task.wait(1)
until task.wait(60)
1 Like

Figured it out, I just use count += 1

until count == (certain number)

repeat
     task.wait(60)
until --something