Roblox's leaderstats rounding feature?

Hello!

Sorry for the weird question. If you didn’t know, Roblox has a rounding feature that is implemented in the leaderboard. My question is: how do I gain access to it to use it myself, or is that even possible?

I tried searching through CoreScripts, but it just lead me through a rabbit hole of requiring other modules.

Also, I meant the rounding feature that adds a letter to the end of the number, representing which illion it’s on. (such as M, B, T, Qd etc…)

Capture d’écran, le 2020-11-17 à 23.48.15

The traditional way (before UICorners existed) was to use a technique called 9-slicing, where parts of an image only scale in certain directions. A plugin called Roundify exists to make this a lot easier. Explained more in detail here

The easiest and most robust way is to use the newly-introduced UICorner. It works on images and gradients, making it infinitely more useful in certain situations, albeit at a minor performance loss.

1 Like

I meant the rounding features for numbers, where it adds a letter that represents which illion it’s on.

These are pretty good:

1 Like

I meant the rounding feature that adds a letter to the end of the number, representing which illion it’s on. (such as M, B, T, Qd etc…)

berezaa open sourced a library from miners haven that roundifies numbers. This should help you a lot!

The module doesn’t has a documentation, so this is the script you should have:

local MoneyLib = require(path.to.MoneyLib)
print(MoneyLib.HandleMoney(1000)) --> should print 1k
3 Likes

Aha…it was hard to tell since it’s a vague question. My apologies.

As for simplifying numbers using suffices, there’s no need for a library. Here’s some code I came up with in five minutes:

local N = {"k", "M", "B", "T", "Qd", --[[...for every power of 3]] }

local function format_number(n)
    local zeros = math.floor(math.log10(n)) -- counts the number of zeros
    local suffix = math.floor(zeros / 3) -- each suffix is every 3rd power
    
    return string.format("%0.1f%s",
        n / 10^(suffix*3),
        N[suffix] or ""
    )
end

format_number(100) -- 100.0
format_number(1337) -- 133.7k
format_number(10000000) -- 10.0M

It’s surprisingly easy once you understand it.

3 Likes