I put this code in a module script and referenced to it in other scripts, and it works, but it only go up to 100T then it goes all funky and says like 1000000000000k or something. Can someone please help.
local abbreviatednumber = {}
local abb = {
k = 4,
M = 7,
B = 10,
T = 13,
Qa = 16,
}
function abbreviatednumber:abb(x)
local text = tostring(math.floor(x))
local chosenabb
for abbreviations, digits in pairs(abb) do
if #text >= digits and #text < (digits + 3) then
chosenabb = abbreviations
break
end
end
if chosenabb then
local digits = abb[chosenabb]
local rounded = math.floor(x / 10 ^ (digits - 2)) * 10 ^ (digits - 2)
text = string.format("%.1f", rounded / 10 ^ (digits - 1))..chosenabb
else
text = x
end
return text
end
return abbreviatednumber
