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

Autoranking ingame for ranks in the group? (Solved) (Answered)

I need some answers for my game. So, I have group ranks on my group. And I wanted to make them auto team in the team they belong so for example.

5 People of the rank "Higher Ranked" wanted to join (Random persons so not configured) And 4 people of the rank "Middle Ranked" wanted to join (Random persons so not configured)

And there are 3 teams: "HR" "MR" "Member"

So that the 5 people go to the team HR And the 4 persons to the team "MR"

Automaticly! So not that the names are in the config!

Can someone help me out?

Not something like below

game.Players.PlayerAdded:connect(function(p) -- When a player join
if p.Name == "AdminName" then -- Check player's name
 
p.TeamColor = BrickColor.new("Really red") -- Change team

 

end

end)

1 answer

✓ Accepted answer

This is an okay script. However, I think you should do this differently. Instead of checking for the player's name, check for his rank on the group instead. To do this, we use the function GetRankInGroup(groupId). This will return the player's rank. Take in mind this returns an IntValue. This does not return the player's Role in the group. The rank is the actual unique number that identifies certain roles. (For example the owner's rank would always be 255)

Anyway... Once you have the rank, use the script below.

-- Variables
local groupId = 3028452 -- Change this to your group's ID
local HighRank = 200 -- Change this accordingly
local MediumRank = 100 -- Change this accordingly
local MembersRank = 1 -- Change this to whatever the Member's rank is
-- // Teams \\ --
local highRankTeamName = "High Ranks" -- Change this to the HR's Team Name
local mediumRankTeamName = "Medium Ranks" -- Change this to the MR's Team Name
local membersRankTeamName = "Members" -- Change this to the Member's Team Name

function getTeam(teamName)
	for i,v in pairs(game.Teams:GetChildren()) do
		if v.Name == teamName then
			return v
		end
	end
end

game.Players.PlayerAdded:connect(function(player)
	if player:GetRankInGroup(groupId) >= HighRank then -- Checks for HR+
		player.Team = getTeam(highRankTeamName)
	elseif player:GetRankInGroup(groupId) >= MediumRank then
		player.Team = getTeam(mediumRankTeamName)
	elseif player:GetRankInGroup(groupId) == MembersRank then
		player.Team = membersRankTeamName
	end
end)

The script above checks if the player's rank is Higher or Equal to a high rank or medium rank. If you want the players who are just in that certain rank and not the one above, replace >= to == in the script accordingly

Hope I helped :)

10 comments

0

Thank you man!

0

Do i need to put this in a local script in the workspace?.

0

ServerScriptService as a script. Also, accept my answer if it's been answered :)

0

How do you do that xD I'm new here :P

0

Right click on ServerScriptService and hover over "Insert Object", find the object "Script", click it and shazam

0

No I mean to set the post to answered

0

If you meant how to accept, it should have the option underneath my answer

0

It only says "Report"

0

That's odd. Underneath MY answer?

0

Fixed

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