It’s impossible to detect change of ranks in group real-time in-game without having to use GetGroupsAsync, which calls longer and having to loop through tables.
Apparently :GetRoleInGroup() & :GetRankInGroup() do not cache on the client;
but say in the player list (leaderstats) where you show the group rank, you’d have to fire over the non-cached call on an interval to check if group has changed from client → server.
The client is awful and never should be trusted.
Can we have something like :GetRoleInGroupAsync() etc?
GroupService doesn’t cache. I would consider the methods mentioned here as legacy functions, but that’s just my opinion.
Anyway, I don’t think it’s worth putting more work into these when we already have a fairly simple way to obtain this data without caching. If anything, these should just be deprecated.
If it’s that much more intensive, then I think a better request would be new methods under GroupService. Having these group functions as part of Player is odd these days, and only made sense back then.
I’m not too familiar with bloating API’s and what is the most efficient in this case but I am not against giving suggestions to help.
Perhaps a second argument to these functions would help?
:GetRoleInGroup(groupID, Cache)
and :GetRankInGroup(groupID, Cache)
This would give developers more control over what caches and what doesn’t. An example would follow like this…
Server
local PlayerService = game:GetService("Players")
PlayerService.PlayerAdded:Connect(function(Player)
Player:GetRankInGroup(1010101, false) -- Doesn't Cache!
end
But if what @Extuls says is true (considering I haven’t tested it) and the yielding functions do not cache then my suggestion is obsolete. I do agree with @Extuls about integrating new methods in GroupService.