Upon attempting to sort a game’s leaderboard to show staff (higher group roles) to appear towards the bottom of the leaderboard using lower Priority values, I discovered that the feature does not work.
One possibility is that the sorting is not working at all as the leaderboard appears to be sorted based on the reverse alphabetical order of the rank names, which is the default behavior.
Video:
Documentation:
Script:
local GroupID = 5613578
local CharHide = 0 --Amount of characters from the beginning to hide
game:GetService('Players').PlayerAdded:Connect(function(p)
local ls = Instance.new('IntValue', p)
ls.Name = 'leaderstats'
local rank = Instance.new('StringValue', ls)
rank.Name = 'Rank'
rank.Value = 'Guest'
if p:IsInGroup(GroupID) then
local xrole = p:GetRoleInGroup(GroupID)
if string.len(xrole) <= CharHide then
warn('[GroupLeaderboard] Attempted to hide more characters than role has; using default name')
rank.Value = xrole
else
local role = string.sub(xrole, CharHide)
rank.Value = role
end
end
local priority = Instance.new('NumberValue', rank)
priority.Name = 'Priority'
priority.Value = 255 - p:GetRankInGroup(GroupID)
end)
Expected behavior
The leaderboard should place players with a higher Priority value at a higher position than those with a lower Priority value.