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

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Wiscript 622 Moderation Voter
6 years ago

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 :)

0
Thank you man! kyanoke11 15 — 6y
0
Do i need to put this in a local script in the workspace?. kyanoke11 15 — 6y
0
ServerScriptService as a script. Also, accept my answer if it's been answered :) Wiscript 622 — 6y
0
How do you do that xD I'm new here :P kyanoke11 15 — 6y
View all comments (6 more)
0
Right click on ServerScriptService and hover over "Insert Object", find the object "Script", click it and shazam Wiscript 622 — 6y
0
No I mean to set the post to answered kyanoke11 15 — 6y
0
If you meant how to accept, it should have the option underneath my answer Wiscript 622 — 6y
0
It only says "Report" kyanoke11 15 — 6y
0
That's odd. Underneath MY answer? Wiscript 622 — 6y
0
Fixed kyanoke11 15 — 6y
Ad

Answer this question