Basically what I am attempting to do is create a function(set after other functions in the script) and use it to change everybodys' team color to blue. Unfortunately, the method I have been using seems to affect only the first person to enter the server.
for i,v in pairs(game.Players:GetPlayers()) do v.TeamColor = BrickColor.new("Bright blue")--This is the team I want it to change to.
If you are wonder this Is in a function so it does run.
So I have two questions that depend on the answers of eachother.
1) Why did it only change the team color of the first person to enter.
2) If there is no apparent reason or it is simply the script, are there any alternatives I can use to fix it? I appreciate you help!
Well, this may help you. It will check what the Players are in the Game, then choose them to become the color, ("Bright blue")
play = game.Players:GetChildren() for i = 1, #play do if play[i]~= nil then play[i].TeamColor = BrickColor.new("Bright blue") end end print("Blue Team") wait(0.1)
Im not sure why you want to change everyone's teamcolor through a script. You can go to the teams, and uncheck "Autojoin:" in every team except the blue team. If that is not the way you want it for some reason, Im going to need the entire function.
function SetTeam(Color) for i,v in pairs(game.Players:GetChildren()) do v.TeamColor=BrickColor.new(Color) end end SetTeam("Bright blue")