Player:GetRankInGroup() is inaccurate, causing anti-cheat to call false positives

Hey there!

Part of my anti-cheat that resides in all of my games is a group check – in a sense, it checks if you are in a verified exploiting group. This is done to put less work on the mods and to prevent more silent exploiters.

The method for this is Player:GetRankInGroup(), which lately has not been properly working. The following code checks if you are in a group:

if player:GetRankInGroup(group_id) > 0 then
   player:Kick()
end

A value greater than 0 will sometimes return, despite the user not being a part of the group. This is causing notable player count drops sometimes. This only happens for some of my game servers, although all are up to date.

Are there any fixes, or is there another way to check if you are in the group reliably?

if player and player:IsInGroup(group_id) then
    player:Kick()
end

or

if player and player:IsInGroup(group_id) then
    if player:GetRankInGroup(group_id) > 0 then
       player:Kick()
    end
end

Can you try it with pcall function?
print(success) and print(error).
Let’s see if it working or not.

I haven’t had great experience with GetRankInGroup for a while now. It often fails even when the API is fine. I actually use GroupService:GetGroupsAsync and look for the group of interest.

1 Like

It does not error, so a pcall is redundant. The issue is that Roblox is saying a user’s rank in a group in greater than 0, even if they are not a part of it.

I’ll be sure to try this method. Thank you!

Oh, well good to hear; that means I didn’t do anything wrong here :stuck_out_tongue:
Should I file a bug report on it?

Well I’ve never personally had it read too high. I’ve only ever had it return zero or error when it shouldn’t. If it’s consistently reading high and you can prove it then I’d make a bug report.

I’d be curious to know if it reads a consistent value, such as 255, when it happens.

Personally I gave up trying to map out the issues I had with it for a bug report as it was quite random.

1 Like