I’m trying to create a ban command that can only be used by players with specific group ranks. I’m having trouble implementing rank-based permissions within the script. I’ve searched the DevForum for solutions but haven’t found a clear guide. I’m looking for guidance on how to check a player’s group rank and restrict the ban command accordingly. Any code examples or suggestions would be greatly appreciated.
There is a method called :GetRankInGroup()
for the player instance, you can get a player’s rank like this:
local group_id = 123456 --// replace this with your group id
local group_rank = Player:GetRankInGroup(group_id)
And then just do an if
statement to check if the player’s rank is higher than the required amount
if group_rank >= 3 then
--// Stuff here
end
Note: ALWAYS do rank checks on the server, never on the client
I think commands aren’t the best way to do this, but if you’re going to use commands, I would first check on the client if they’re high enough rank and send it to the server to check as well. You can use
Player:GetRankInGroup(ID)
and restrict it to a certain rank and higher. In the group configuration menu you can see the rank values. I think it’s 0 - 255.
Why would you check it on the client? It’s pointless, they can not be trusted.
Thank you, I really appreciate it.
To avoid unnecessarily checking on the server. If someone that wasn’t even exploiting chose to spam, it could meet a quota and prevent people that need to use it to use it.
:GetRankInGroup() caches, so it only checks the rank when it’s called the first time and returns the first result only. There is no quota.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.