Team switch script not working

Hey all.

I am coding an auto group team switch system for my game, but for some reason, it’s not working. Whenever I join the game I am on a random team. The script is in SSS and I have disabled auto assign on the teams. I also turned off Neutral on the spawn point.

game.Players.PlayerAdded:Connect(function(player)
	if player:GetRoleInGroup(32029896) == "KGB" then
		player.Team = game.Teams.KGB
	end
	if player:GetRoleInGroup(32029896) == "Director" or "Deputy Director" or "Assistant Director" then
		player.TeamColor = game.Teams["Board of Directors"]
	end
	if player:GetRoleInGroup(32029896) == "Red Army Soldier" then
		player.Team = game.Teams.Army
	end
end)
local Teams = {
	["KGB"] = "KGB",
	["Director"] = "Board of Directors",
	["Deputy Director"] = "Board of Directors",
	["Assistant Director"] = "Board of Directors",
	["Red Army Soldier"] = "Army"
}
game:GetService("Players").PlayerAdded:Connect(function(Player)
	if table.find(Teams, Player:GetRoleInGroup(32029896)) then
		Player.Team = game:GetService("Teams"):FindFirstChild(Teams[Player:GetRoleInGroup(32029896)])
	end
end)
1 Like

It’s still not working. It must be an issue with the teams or the spawn location.

Are you using the right group id? If so, how about role names?

Are you doing this in a serverscript or localscript?

Serverscript.

character limit smh

i did some reading again and why does the coding at the board of directors role say player.TeamColor and not
player.Team, could that be the issue?