Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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!

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.