So, I have a global leaderboard and it works perfectly! But the problem is, that the numbers are often above 10,000, meaning that the numbers all look squashed, etc.
I want to convert any numbers above 10,000 to show 10k, so if the number was e.g. 32415, it would display as 32k. I thought about using math.floor(), but that just gets rid of the decimals. My numbers don’t have decimals.
local function Convert(Number)
end
I wrote the code above, but I don’t know how to convert it.
How can I achieve this?
You can use my custom function that does a lot more than K, it adds M and B and more!
local T = {"K","M","B","T","q","Q","s","S","O","N","d","U","D"}
local function formatNumber(n)
if not tonumber(n) then return n end
if n < 10000 then return math.floor(n) end
local d = math.floor(math.log10(n)/3)*3
local s = tostring(n/(10^d)):sub(1,5)
return s.." "..tostring(T[math.floor(d/3)])
end