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

A fix for a for loop in while loop?

Asked by 10 years ago

Hi, I'm scripting a game. Quite simple indeed. I am having a problem with a script, though.

while players < 3 do
    for _,v in pairs(game.Players:GetChildren()) do 
        players = players + 1
        print("for 1:".. players)
    end
    wait(2)
end

It works and all, but the only thing is that when for example, one person joins, every 2 seconds, players increase by one. So in the command it looks like for 1:1, for 1:2. This is not how I want it to be. I want it so players is set to the amount of players in the server. If anyone kindly helps me to figure out how to do this, I would be VERY grateful. Thanks!

-Cookaie

Answer this question