My auto team script does not team players correctly

Hello guys, I need help with this team script. It does not team players correctly and I am unsure why it does so.

game.Players.PlayerAdded:Connect(function(player)

    if player:GetRankInGroup(13767730) > 1 then
        player.Team = game.Teams["Army Headquarters"]
    elseif player:GetRankInGroup(15350427) >= 1 then
        player.Team = game.Teams["Australian International Relations Committee"]
    elseif player:GetRankInGroup(15332038) >= 1 then
        player.Team = game.Teams["Royal Australian Regiment"]
    elseif player:GetRankInGroup(15692214) >= 1 then        
        player.Team = game.Teams["Australian Aviation Corps"]
    elseif player:GetRankInGroup(15483890) >= 1 then
        player.Team = game.Teams["Defense Intelligence Organization"]
    elseif player:GetRankInGroup(15323353) >= 1 then
        player.Team = game.Teams["Officer Training School"]
    elseif player:GetRankInGroup(15331112) >= 1 then
        player.Team = game.Teams["Special Air Service Regiment"]
    elseif player:GetRankInGroup(11297312) >= 1 then
        player.Team = game.Teams["Australian Military Police"]
    elseif player:GetRankInGroup(13016458) >= 1 then
        player.Team = game.Teams["Australian Training Services"]
    elseif player:GetRankInGroup(14565071) <= 10 then
        player.Team = game.Teams["Army Personnel"]
    end
end)

Have you put print statements in to find out what line it is failing on?

No, I have not.
I will try that now.

What is the system suppose to do? From what I can see… every player that joins is a Army Headquaters.

First of all, line 1 of the if statement:

If their group rank is above 1, then give them that team. So, the script stops.

I was assumming this first group you check is the main group.

It does give it the team, or am I missing something? The script is meant to team players based of what group they are in

Is the first check the main group? If so, put it at the end of the if statement.

No, it’s not. It’s the HQ group

Maybe try to format it like this?

game.Players.PlayerAdded:Connect(function(player)
if player:GetRankInGroup(13767730) > 1 then
	player.Team = game.Teams["Army Headquarters"]
end
if player:GetRankInGroup(15350427) >= 1 then
	player.Team = game.Teams["Australian International Relations Committee"]
end	
if player:GetRankInGroup(15332038) >= 1 then
	player.Team = game.Teams["Royal Australian Regiment"]
end
if player:GetRankInGroup(15692214) >= 1 then        
	player.Team = game.Teams["Australian Aviation Corps"]
end
	if player:GetRankInGroup(15483890) >= 1 then
	player.Team = game.Teams["Defense Intelligence Organization"]
end
if player:GetRankInGroup(15323353) >= 1 then
	player.Team = game.Teams["Officer Training School"]
end
if player:GetRankInGroup(15331112) >= 1 then
	player.Team = game.Teams["Special Air Service Regiment"]
end
if player:GetRankInGroup(11297312) >= 1 then
	player.Team = game.Teams["Australian Military Police"]
end
if player:GetRankInGroup(13016458) >= 1 then
	player.Team = game.Teams["Australian Training Services"]
end
if player:GetRankInGroup(14565071) <= 10 then
	player.Team = game.Teams["Army Personnel"]
end
end)
1 Like

Thank you fine sir, you saved our game as we release soon!

I’m so glad it worked! I was hoping it would, haha. Good luck on your game!

1 Like