How do I check 2 things at the same time in a repeat wait()?

How do I do that? This is my script:

local battle = true
local players = {
    "Player1",
    "Player2"
}

coroutine.wrap(function()
    wait(180)
    battle = false
end

coroutine.wrap(function()
    repeat wait() until #players <= 1
    battle = false
end

repeat wait() until battle == false
print("Game Over!")

I want the game to end if there are 1 or less players or if the time runs out. How do I do that?

1 Like

You can add a check within the repeat wait function, and if it meets the requirements, break

repeat
	wait()
	if battle == false then
		break
	end
until #players <= 1
2 Likes

alternatively, you could do this.

repeat
 wait()
until battle == false or #players <= 1
3 Likes