Team not setting correctly

  1. What do you want to achieve?
    User to join the custom team.
  2. What is the issue?
    Roblox is setting the Player’s Team to the wrong team.
  3. What solutions have you tried so far?
    Looked into the API usage for teams and noticed this, but I’'m setting the Team value itself and not TeamColor

Changing Player.TeamColor will cause Player.Team to switch to the Team with the corresponding Team.TeamColor

--Server Side Script | ServerScriptService
local Team = Instance.new("Team");
Team.Name = "Team";
Team.TeamColor = BrickColor.new(Color3.fromRGB(0,255,255));
Team.Parent = game:GetService("Teams");

game.Players.PlayerAdded:Connect(function(Player)
	warn("Old Team:",Player.Team) --> Old Team: Team
	local NewTeam = Instance.new("Team");
	NewTeam.Name = "NEW_TEAM";
	NewTeam.TeamColor = BrickColor.new(Color3.fromRGB(0,255,255));
	NewTeam.Parent = game:GetService("Teams");
	NewTeam.AutoAssignable = false;
	
	Player.Team = NewTeam;
	warn("New Team:", Player.Team); --> New Team: Team
end)

Is there no way around this?

The team colors for Team and NEW_TEAM are the same in BrickColor. Try changing NEW_TEAM's team color to something like… 255,255,0.

Oh and also, replace Player.Team = NewTeam with Player.TeamColor = NewTeam.TeamColor, otherwise it will not work.

Hope this helps

So is there really no way without changing the colors?

Nope. Even if you did it manually by creating two teams with the same color, that would still happen.

Don’t like the undocumented behaviour but thanks I guess.

Player.Team = game:GetService("Teams").NEW_TEAM

This would also be adequate.

No, if two teams share the same color it throws a fit.

Yes, hence if you set the team of a player by assigning a Team instance to the “Team” property of the player instance any team color collisions are avoided.

Incorrect, but thanks for trying.

local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local team1 = teams.Red1 --this team uses Really red brickcolor
local team2 = teams.Red2 -- this team also uses Really red brickcolor

player.Team = team1 --this assigns player to the team "Red1"
player.Team = team2 -- this assigns player to the team "Red2"

Hopefully it makes more sense to you like this.

No that doesn’t work, have you tried the code I provided?