How do I get a player's rank by its name. (not Rank#)

Hello, I am trying to make a developer application for a group that I am Co-Owner in, however, the owner has 2 ranks with Rank# of 1. I want the application to kick you if you are above rank Member.

Any help would be great! Thank you.

2 Likes

First off, all group roles will have the name along with the rank ID. If the rank ID is the same for 2 roles, I’d recommend changing that, as it will interfere with the code! With this being said, we can use this script to assist us further with this:

local RankId = 1
local GroupId = 0 -- Change 0 to your group ID!
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Client)
    if Players[Client] and Client:GetRankInGroup(GroupId) > RankId then
        Client:Kick("Your access is prohibited!")
    end
end)

This should work, let me know problems you come across regarding this thread! :grin:

3 Likes

I cannot change the Rank ID due to my permissions.

Are you able to contact the group owner?

Yes. I can contact the group owner. I’ll try doing that.

Use plr:GetRoleInGroup(GroupID) which returns the rank name and not ID.