I've been trying to make some games that have a working round system in it. For the simple games that I tried to make, it worked perfectly. However, when I got into the more complex games with multiple different ways that the round could end, I didn't know what to use for a round system. When I say "what to use" I mean the use of while loops, for loops, changed events, etc. What I used for both of my games is a while wait() do loop (yes I know I shouldn't do that, its a habit that I'm trying to get rid of). The script looked something like this:
local RoundInProgress = game.ServerStorage.RoundInProgress
while wait() do
if #game.Players:GetPlayers() < 2 then
game.ReplicatedStorage.Status.Value = "Two or more players are required to start..."
elseif #game.Players:GetPlayers() >= 2 and RoundInProgress.Value == false then
RoundInProgress.Value = true
-- Choose roles
-- Choose map
-- Teleport players
else
wait(1) --[[ I added this because there seemed to be an alternative somehow that
caused the loop to stop running. I don't know how that could be the case but
the addition of the else seemed to fix it.]]
end
This seemed like a really good way to do a round system to me, until I tried to end the game when too many players left. When I did that, the players would teleport back and the round would never start again even though I got no errors. What I tried to do instead of just changing the variables is a force reset. I set a bool value to true and the script that was connected to the changed event would delete all the scripts and paste it back in. The problem with this was that every time a round started the map would destroy and the intermission would start again.
I'm not sure if the backstory was needed, but what I'm asking is what you guys would use to make a round system for your games. Thanks in advance.

2 comments
Did you make it so when a round ends it makes RoundInProgress.Value = false?
I would use a corortine.wrap function.