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

Why is this script doing this?

The script I have here I am using to(at random) select someone to be on the orange team. The problem is that when there are two(or more) people on the game it runs it for the amount of players on the game.

players = game.Players:GetPlayers()
for i,v in pairs(game.Players:GetPlayers()) do
if #players >= 1 then
	first_infected = players[math.random(1, #players)]
	first_infected.TeamColor = BrickColor.new("Bright orange")--This is all in a function so it will run.

So my question is: How can I make it so it only changes the team of one person at one time? Hope this make sense

Thanks

1 answer

✓ Accepted answer

Simply remove your loop. There isn't a reason for there to be a loop here; no operation is "per player", there is just a single thing happening that happens to use a list of players.

1 comment

0

Facepalm on my part. Thanks... again :)

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