Hello, I am trying to make it so it order correctly an example being 100 Billion is higher than 101 Million.
Since there is a number limit to leaderstats value I am abbreviating values and as you can see in the screenshot it causes issue, since it consider I only have 1 I’m one of the lowest player while player with higher numbers are higher.
Another example is that imagine I have 10 Billion of a value and someone else has 11K, the player with 11K will be higher than me.

Hey! The issue you’re facing happens because the leaderboard is sorting the text (like "1.0B"
and "80.8K"
) instead of the actual number. Text sorting treats "1.0B"
as lower than "80.8K"
alphabetically, which isn’t right numerically.
The solution is to:
- Store the real number in the leaderboard stat.
- Use that for sorting and comparisons.
- Only use the abbreviated string for display.
Here’s a quick example script that does exactly that:
Script (put in ServerScriptService
or wherever your stats are handled):
-- Function to abbreviate large numbers (e.g. 1500000 -> "1.5M")
local function abbreviateNumber(n)
if n >= 1e12 then
return string.format("%.1fT", n / 1e12)
elseif n >= 1e9 then
return string.format("%.1fB", n / 1e9)
elseif n >= 1e6 then
return string.format("%.1fM", n / 1e6)
elseif n >= 1e3 then
return string.format("%.1fK", n / 1e3)
else
return tostring(n)
end
end
game.Players.PlayerAdded:Connect(function(player)
-- Create leaderstats container
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Create real number stat for sorting
local speed = Instance.new("IntValue")
speed.Name = "Speed"
speed.Value = 1000000000 -- example value (1.0B)
speed.Parent = leaderstats
-- Optional: send abbreviated display to player via PlayerGui
local guiValue = Instance.new("StringValue")
guiValue.Name = "SpeedDisplay"
guiValue.Value = abbreviateNumber(speed.Value)
guiValue.Parent = player:WaitForChild("PlayerGui")
-- Keep the display updated if Speed changes
speed.Changed:Connect(function()
guiValue.Value = abbreviateNumber(speed.Value)
end)
end)
I’m not sure but isn’t there a limit to leaderstats values? (Not display)