This script changes the team for each player, how do I make it go one by one, and put a player on a team, depending on the values of rval and dval?
rval=0 dval=0 for k, p in pairs(game.Players:GetPlayers()) do if rval<=dval then p.TeamColor=BrickColor.new("Bright red") elseif dval<rval then p.TeamColor=BrickColor.new("Bright blue") end end end end end) end)
I can't see a big error, you just forgot something and it's a bit disorganized. Look:
rval = 0 dval = 0 for i, player in pairs(game.Players:GetPlayers()) do if rval < dval then player.TeamColor = BrickColor.new("Bright red") rval = rval + 1 -- you forgot to add the new player to the team value elseif rval > dval then player.TeamColor=BrickColor.new("Bright blue") dval = dval + 1 -- and here too else player.TeamColor = BrickColor.new("Bright red") -- just to start spreading them rval = rval + 1 end end -- no use for those ends
local switch = true for i,v in pairs(game.Players:GetPlayers()) do v.TeamColor = (switch and BrickColor.new("Bright red") or BrickColor.new("Bright blue")) switch = not switch end