So I was just wondering what is the best way of creating a round system. I have a basic idea in that you do a while true loop but I can’t seem to be able to think of a good way checking if the server still has the correct amount of players or not. I could do if statements in ever section but the issue with this is that I would be having loads of if statements doing the same thing so I was wondering if anyone had a better idea of how to do this.
So I had a quick read but I don’t see how this would fix my issue of checking if the server player count meets the required count. Also I don’t think is would work very well for what I am looking for because I want stuff to happen during the game period not just waiting until the end.
I mean first of all you should not have a wait in the while loop but also yea that works for the first time but when the game is playing there is no way for it to check if the count still meets the required players.
You can use a ‘for’ loop that acts as the timer and checker while the game goes on.
local RequiredPlayers = 2
local RoundDuration = 500
while task.wait(1) do
if #game.Players:GetChildren() >= RequiredPlayers then
for i = 1, 500 do
print(i) --Time left
if #game.Players:GetChildren() < RequiredPlayers then
break
end
else --Not enough players :(
end
I use that version because my game has a clock displaying the time.
True, there are better ways, such as checking for the :ChildRemoved() event in players.
But it’ll take a bit longer to script since you have to relay it to the round system loop.