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!

01game.Players.PlayerAdded:connect(function(Plyr)
02Plyr.CharacterAdded:connect(function(Char)
03wait()
04if Plyr:IsInGroup(4878928) then
05Char:MoveTo(script.Parent.Position)
06Plyr.TeamColor = BrickColor.new("Really black" ..script.Parent.TeamColor)
07else
08end
09end)
10end)
11 
12--How to make rank spawns?
13 
14--?

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)

01local GroupId = 4878928
02 
03game.Players.PlayerAdded:connect(function(Plyr)
04    Plyr.CharacterAdded:connect(function(Char)
05        wait()
06 
07        if Plyr:IsInGroup(GroupId) then
08            local rank = Plyr:GetRankInGroup(GroupId)
09            if rank == 255 then -- owner
10 
11            elseif rank == 50 then -- rank 50
12 
13            else
14                print('Everyone else')
15            end
View all 22 lines...

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:

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

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

01game.Players.PlayerAdded:Connect(function(player)
02    player.CharacterAdded:Connect(function(char)
03        if player:IsInGroup(4878928) then
04            local rank = player:GetRankInGroup(4878928)
05 
06            if rank == ownerID then
07                player.TeamColor = groups["owner"];
08            else if rank == adminID then
09                player.TeamColor = groups["admin"];
10            else
11                player.TeamColor = groups["default"];
12            end;
13        else
14            player.TeamColor = groups["default"];
15        end;
16    end);
17end);

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