For anyone who has played MarineAstrius' USMC I want a team system exactly like that. For anyone that hasn't essentially you have the main USMC group with all the ranks. then affiliated with that group you have all the divisions. So for example lets say I was in TECOM when I first join the server I am in the visitor team, then I join the Main USMC group and I go to Recruit Training team, then after my training and promotion within the main group (ranked to Private) I join the game and am in the divisionless team because I have not joined a division, but once I have joined let's say the TECOM group affiliated to the main group I am auto teamed into the TECOM team. I have had an attempt at this but I am honestly terrible with code and have never really done it before so if someone understands what I am asking and knows how to help thank you so much.

This is the code that I have done it's probably really bad but it doesn't work anyway.


Team = game.Teams:findFirstChild("1 Marine Expeditionary Force")
Team2 = game.Teams:findFirstChild("Divisionless")
Team3 = game.Teams:FindFirstChild("Headquarters")
Team4 = game.Teams:findFirstChild("Jailed") 
Team5 = game.Teams:findFirstChild("Military Police")
Team6 = game.Teams:findFirstChild("Office Of The Inspector General")  
Team7 = game.Teams:findFirstChild("Recruit Training")
Team8 = game.Teams:findFirstChild("Training and Education Command")
Team9 = game.Teams:FindFirstChild("Visitors")


function onEntered(newPlayer) 
	if newPlayer:GetRankInGroup(968694) == 0 then --Visitor
		newPlayer.TeamColor = Team9.TeamColor 
	
	elseif newPlayer:IsInGroup(968694) == 1 then -- Recruit Training
		newPlayer.TeamColor = Team7.TeamColor	
		
	elseif newPlayer:GetRankInGroup(968694) > 1 then --Divisionless
		newPlayer.TeamColor = Team2.TeamColor	
		
	elseif newPlayer:GetRankInGroup(9745706) > 1  then --1 Marine Expeditionary Force
		newPlayer.TeamColor = Team.TeamColor

	elseif newPlayer:GetRankInGroup() > 1 then --Jailed
		newPlayer.TeamColor = Team4.TeamColor

	elseif newPlayer:GetRankInGroup(9745856 > 1 then --MP
		newPlayer.TeamColor = Team5.TeamColor

	elseif newPlayer:GetRankInGroup(9746143) > 1 then --Office Of The Inspector General
		newPlayer.TeamColor = Team6.TeamColor

	elseif newPlayer:GetRankInGroup(9745576) > 1 then --Training and Education Command
		newPlayer.TeamColor = Team8.TeamColor
		
	elseif newPlayer:GetRankInGroup(9793860) > 246 then --Headquarters
		newPlayer.TeamColor = Team3.TeamColor

		wait(0.5)
		newPlayer:LoadCharacter()
	end 
end 

game.Players.ChildAdded:connect(onEntered)