I need it in a script when a certain event happens, it changes the players team. I need the below script to choose random teams.
--------------------------
-- Random map is chosen --
--------------------------
if game.Players.NumPlayers > 1 then
h.Value = "Deciding what map to play"
wait(3)
ranMap = math.random(1, #map)
mapChosen = map[ranMap]
h.Value = "Map Chosen: " .. mapChosen.Name
wait(2)
mapChosenClone = mapChosen:Clone()
mapChosenClone.Parent = game.Workspace.MapHolder
wait(2)
------------------------
-- Picks random teams --
------------------------
players = game.Players:GetChildren()
teams = {"Bright red","Bright blue"}
num = 1
for i,v in pairs(players) do
v.TeamColor = BrickColor.new(teams[num])
num = num + 1
if num > #teams then
num = 1
end
end

11 comments
What are you asking? Can you be more clear, this would change the TeamColor of each player.
So you want it to work how it is, except the players go on random teams instead of back and forth?
I want it so that the players are split into two teams. Red and blue, so I need this script to change a players current team to either red or blue
Cuase it itsnt working, it does nothing
When do you want to run it? As of now you are just running it right away (when the server is created) so at that time there will be no players.
ill add what comes before and after
im not posting the whole thing, cause theres 150+ lines to the actual script
Are you positive the player(s) are not neutral when you change their teamcolor? You can manually set their neutral property to false but other than that it seems fine. Is there an output?
k thanks, that was the problem, thanks LD
except now when your character dies they dont repsawn at a spawn
Make sure the TeamColor of the spawn matches the team's TeamColor and that the spawn is not neutral