Non-Caching Extended Group Functions
Hello DevForum, some weeks ago I made a module that allows me to retrieve the group rank / role of a user without having it cache, and some days ago I extended the module to have many other functions like checking if the user is in the groups clan or if the user set the group as the primary group.
The module entirely works with UserIds, which means that you can even use it on players who are currently not playing your game.
It is both available on GitHub and as a Module. You can grab the module here or you go to the GitHub Page and run the installer in your command line. With the newest version, you can also require it with require(2477978137)
to always stay on the latest version.
The installer retrieves the latest version of the module and adds an example into ServerScriptService.
Example
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local GetModule = function(dir, name) return dir:FindFirstChild(name) and require(dir:FindFirstChild(name) or {} end
local GroupService, GroupServiceOffline = GetModule(ReplicatedStorage, "GroupService")
local GROUP_ID = 0
--------------------------------------
-- Online Example
function playerAdded(player)
local groupRank, isPrimary = GroupService:GetRankInGroupAsync(player.UserId, GROUP_ID),
GroupService:IsPrimaryGroupAsync(Player.UserId, GROUP_ID)
print("Group Rank:", groupRank)
print("Is Primary:", isPrimary)
end
--------------------------------------
-- Offline Example
function getUserInfo(userId)
local groupRank, isPrimary = GroupService:GetRankInGroupAsync(player.UserId, GROUP_ID),
GroupService:IsPrimaryGroupAsync(userId, GROUP_ID)
print("Group Rank:", groupRank)
print("Is Primary:", isPrimary)
end
The API Documentation can be found here.