Hello.
I'm new to Roblox, so excuse me if this question is stupid, but I didn't find anything in wiki.
I've created 2 teams "Mafias" and "Policemen". For now, I assign all players to mafias team. But in-game, every player gets Policemen team, I don't know why.
My code:
local mafiaTeam = nil
local policeTeam = nil
function onPlayerAdded(player)
player.Neutral = false
player.TeamColor = mafiaTeam.TeamColor -- set to mafia
end
function setUp()
mafiaTeam = Instance.new("Team", Game:GetService("Teams"))
mafiaTeam.Name = "Mafias"
mafiaTeam.TeamColor = BrickColor.Red()
policeTeam = Instance.new("Team", Game:GetService("Teams"))
policeTeam.Name = "Policemen"
policeTeam.TeamColor = BrickColor.Blue()
end
setUp()
Game.Players.PlayerAdded:connect(onPlayerAdded)
What's the problem? If you can figure it out, help me please.
Thanks in advance
UPDATE: as it seems to be, the problem is with GUI. Physically, I'm in mafias team (I've checked player's properties with server console + my name color is red, as it should be if I'm in mafias team), but GUI shows that I'm in policemen team. Any suggestions?

3 comments
I think this is most likely just a time issue -- I believe your script is working and it's simply acting too soon and the ROBLOX game is overriding your change. Try adding a wait(1) to the beginning of the player event. (I can't run this code to test). Remember that you can use Tools -> Start Server and Tools -> Start Player to test things like this from Studio and get output!
Thanks, but that didn't help. However, I've checked the player's TeamColor and it's set to 'Bright red', but in the GUI I see that he's in Policemen team.
Here is the screenshot of GUI http://yadi.sk/d/73Pknat1MZwPx