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)