#For Loop Skipping at Random

18 messages · Page 1 of 1 (latest)

echo willow
#

Idk why but every time ive tested using the local server of 8 people, it randomly skips 2 to 3 players and leaves them without a team. Im not sure why could someone help me pls. I suck at scripting

timber holly
#

Weird way to do a for loop...
Just do this:

for i = 1, #Waiting:GetPlayers(), 1 do
  Waiting:GetPlayers()[i].Team = CrewMate
end
echo willow
#

that makes more sense

#

tried that and it is still skipping

#

just 1 for a server of 4

#

and 3 in a server of 8

timber holly
#

Do a print for Waiting:GetPlayers()

hearty forgeBOT
#

studio** You are now Level 1! **studio

echo willow
#

it only registered 2 from the start when there is 3

echo willow
#

nevermind it jusr cant complete it when there is one left

#

but with 8 players it stops with 3 remaining

#

and says its now nill

pine idol
#

then player.Team = CrewMate

#

Remove the 'i' variable

pine idol
#

Judging from what ur trying to make, if u want there to be a x impostors and totalPlayere-x crewMates then u could make a function called SetupGame where you select x amount of impostors and then select totalPlayers-x crewMates