so like half a year ago i made a post because i had a bug with the abbreviation system thing and someone helped me and gave me a code, altho now that i wanted to use it again i noticed a bug
the bug was when im getting a number like 100000 its just saying K and not 100K
i didnt wrote the code so i dont really understand it so much
here is my code, if someone helps im very thankful
function Abbreviate(value)
local abbreviations = {
"K", -- 4 digits
"M", -- 7 eigits
"B", -- 10 digits
"T", -- 13 digits
"Qu", -- 16 digits
"Qi", -- 19 digits
"Sx", -- 22 digits
"Se", -- 25 digits
"Oc", -- 28 digits
"No", -- 31 digits
"De", -- 34 digits
"Un", -- 37 digits
"Duo", -- 40 digits
"Tre", -- 43 digits
"Qua", -- 46 digits
"Qui", -- 49 digits
}
local newstring = ""
if value >= 1e+3 and value < 1e+6 then
local args = string.split(tostring(value / 1e+3), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[1]
end
if value >= 1e+6 and value < 1e+9 then
local args = string.split(tostring(value / 1e+6), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[2]
end
if value >= 1e+9 and value < 1e+12 then
local args = string.split(tostring(value / 1e+9), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[3]
end
if value >= 1e+12 and value < 1e+15 then
local args = string.split(tostring(value / 1e+12), "")
local isperiod = false
local ready = false
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[4]
end
if value >= 1e+15 and value < 1e+18 then
local args = string.split(tostring(value / 1e+15), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[5]
end
if value >= 1e+18 and value < 1e+21 then
local args = string.split(tostring(value / 1e+18), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[6]
end
if value >= 1e+21 and value < 1e+24 then
local args = string.split(tostring(value / 1e+21), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[7]
end
if value >= 1e+24 and value < 1e+27 then
local args = string.split(tostring(value / 1e+24), "")
local isperiod = false
local ready = false
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[8]
end
if value >= 1e+27 and value < 1e+30 then
local args = string.split(tostring(value / 1e+27), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[9]
end
if value >= 1e+30 and value < 1e+33 then
local args = string.split(tostring(value / 1e+30), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[10]
end
if value >= 1e+33 and value < 1e+36 then
local args = string.split(tostring(value / 1e+33), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[11]
end
if value >= 1e+36 and value < 1e+39 then
local args = string.split(tostring(value / 1e+36), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[12]
end
if value >= 1e+39 and value < 1e+42 then
local args = string.split(tostring(value / 1e+39), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[13]
end
if value >= 1e+42 and value < 1e+45 then
local args = string.split(tostring(value / 1e+42), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[14]
end
if value >= 1e+45 and value < 1e+48 then
local args = string.split(tostring(value / 1e+45), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[15]
end
if value >= 1e+48 and value < 1e+51 then
local args = string.split(tostring(value / 1e+48), "")
local isperiod = false
local ready = false
local nextnum
for i,v in pairs(args) do
if not ready then
if isperiod then
newstring ..= v
if not nextnum then
nextnum = true
else
ready = true
end
else
newstring ..= v
if v == "." then
isperiod = true
end
end
end
end
newstring ..= abbreviations[16]
end
if string.len(newstring) == 0 then
newstring = tostring(value)
end
newstring = string.gsub(newstring, ".00", "")
return newstring
end
thanks again if someone is willing to help