Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it good to put a repeat inside of a while true do loop making a round system?

Asked by 3 years ago

I need to make it so that I make sure there are 2 players or more to start the game heres the code

while true do

    repeat wait()


        print("hey") 

    until #PlayersService:GetPlayers() >= 2 





    wait()
end
0
Nothing wrong with this. Though, what SkiH1gh said is better than polling the game. radiant_Light203 1166 — 3y

1 answer

Log in to vote
1
Answered by
SkiH1gh 14
3 years ago

So the thing you would probably want to do is have a bool value and set it to false. call this the roundEnabled. Reference the value of it in your script as "Enabled".

now do a game.Players.ChildAdded:Connect(function()end) --note this must be in a server side script to work

when a player joins, check if Enabled == false

Now do if #game.Players:GetChildren() >= 2 then --[[round code]] end

If it is, set the enabled value to true. Now when a player joins, it checks if the round is disabled, and if it is whenever a player joins, it will check if the player count is over 2, and if it is it will set enabled to true and let players do the round.

Ad

Answer this question