Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Nothing wrong with this. Though, what SkiH1gh said is better than polling the game.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.