Create teams with the names of the group ranks in the teams service. Then, iterate through the players service with an “in pairs” loop and assign them the team.
for _,player in pairs(game.Players:GetChildren()) do --Indexes each player individually
local GroupRank = player:GetRankInGroup(Your group id here)
player.Team = game.Teams:FindFirstChild(GroupRank) --Looks for the group rank's name in the teams service and assigns it to the player.
end
local Team1 = game:GetService("Teams"):WaitForChild("Team1")
local Team2 = game:GetService("Teams"):WaitForChild("Team2")
local Group = GROUP_ID
local Rank1 = 50
local Rank2 = 25
function onPlayerAdded(Player)
local PlayerRank = Player:GetRankInGroup(Group)
if PlayerRank >= Rank2 and not (PlayerRank >= Rank1) then
Player.Team = Team1
elseif PlayerRank >= Rank1 then
Player.Team = Team2
end
end
game:GetService("Players").PlayerAdded:Connect(onPlayerAdded)