Team changer not working

I’ve got a script that changes teams for the player. It goes off a table, and when the player hits a button the event fires with the name of the team they want to join. This is the server script:

game.ReplicatedStorage.ChangeTeam.OnServerEvent:Connect(function(player, team)
	if team == "Class D" then
		player.TeamColor ="Deep orange")
	elseif team == "Scientific Department" then
		player.TeamColor ="Really blue")
	elseif team == "Ethics Committee" then
		player.TeamColor ="Shamrock")
	elseif team == "Foundation Personnel" then
		player.TeamColor ="Medium stone grey")
	elseif team == "Manufacturing Department" then
		player.TeamColor ="Eggplant")

The team doesn’t change, however the player’s character loads. Help’s appreciated. Thanks.

1 Like

Try making sure the player has a team before trying to change it( so add a check to see what the player team is by doing print(player.Team.Name) also, you can set team by simply setting the team name to whatever name the team is. Instead of relying on TeamColor. And I believe the default team is “Neutral”.

Try change

player.TeamColor =


player.Team = game.Teams[team]
1 Like

I have no idea why I didn’t try that. Thank you!