Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to sort players into teams based off their group rank?

Asked by
ANE_bot 17
5 years ago

I need to know how to put players in teams based on a group? like, if you are a site manager, it will put you in the site administration team. Thanks for the help!

game.Players.PlayerAdded:connect(function(Plyr)
Plyr.CharacterAdded:connect(function(Char)
wait()
if Plyr:IsInGroup(4878928) then
Char:MoveTo(script.Parent.Position)
Plyr.TeamColor = BrickColor.new("Really black" ..script.Parent.TeamColor)
else
end
end)
end)

--How to make rank spawns?

--?

if it helps: https://web.roblox.com/groups/4878928/Alfa-Labs#!/about

2 answers

Log in to vote
0
Answered by
IDKBlox 349 Moderation Voter
5 years ago
Edited 5 years ago

for this you're going to want :GetRankInGroup(Id)

local GroupId = 4878928

game.Players.PlayerAdded:connect(function(Plyr)
    Plyr.CharacterAdded:connect(function(Char)
        wait()

        if Plyr:IsInGroup(GroupId) then
            local rank = Plyr:GetRankInGroup(GroupId)
            if rank == 255 then -- owner

            elseif rank == 50 then -- rank 50

            else
                print('Everyone else')
            end
            Char:MoveTo(script.Parent.Position)
            Plyr.TeamColor = BrickColor.new("Really black" ..script.Parent.TeamColor)
        else

        end
    end)
end)

If you have any questions, feel free to ask!

Ad
Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
5 years ago
Edited 5 years ago

You can make a list with color names for the groups like so:

local groups = {
    owner = BrickColor.new("Really black"),
    admin = BrickColor.new("Dark grey"),
    default = BrickColor.new("Mid gray")
}

You can then do your check when they join, and assign them the right team like so:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        if player:IsInGroup(4878928) then
            local rank = player:GetRankInGroup(4878928)

            if rank == ownerID then
                player.TeamColor = groups["owner"];
            else if rank == adminID then
                player.TeamColor = groups["admin"];
            else
                player.TeamColor = groups["default"];
            end;
        else
            player.TeamColor = groups["default"];
        end;
    end);
end);

You can do the same for locations and teleport them to locations.

Make sure that you create the team objects with the same colors as you define in your code. You can then give them any name you want in the Teams folder.

Answer this question