First off, you might want to make sure your conditions are being set properly.
Second off, assigning teams based on color isn’t a good idea at all. Try to change the code to incorporate the Player.Team property. The wiki also has a tutorial on assigning players to teams.
As for checking group roles, you have a good start on how to do that, but I would look at other posts made here as this question has been asked multiple times.
local TeamNames = {[" (team name) "] = " (group rank name) "} -- you can add more by putting ,[" (team name) "] = " (group rank name) "
game:GetService("Players").PlayerAdded:Connect(function(player)
player.Team = game:GetService("Teams")[TeamNames[player:GetRoleInGroup(GROUPID)]] -- change GROUPID to your group id
end)