Abbreviation system bug

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

Thats lot of lines of script i recomended watch this video it has just small lines of scripts:

they are not the same things, my script does
1000 = 1k
1001 = 1k
1010 = 1.01k
1100 = 1.1k
1110 = 1.11k
etc.

but the problem comes when its numbers like 100k
then it only says K

please someone helpppp (,)

I haven’t tested this because I’m in school right now, but if it doesn’t work I can fix it in an hour.

local Digits = {"K", "M", "B", "T", "Qu", "Qi", "Sx"}

local function Abrieviate(Number)
       local digits = string.len(tostring(Number)) - 1
       local iterations = math.floor(digits/3)
       if iterations > 0 then
            local letter = Digits[iterations]
            local number = math.floor(Number/((10^(iterations * 3))/100))/100
            return number..letter
       else 
           return Number
       end
end

print(Abrieviate(9877652)) --- Should return 9.87M

yes its working! thank you very much marked as solution

1 Like

Glad to hear that it works! If you have any questions on why it works feel free to ask.

hey, i tested the things i gave a random number 51305019531059013
and it said 0.05Qi

how can i fix this bug???

and i tried giving one more number (5831580173580137510835170587135) and it gave -9.23Qi

this is the digit things btw

local Digits = {
	"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
}

the numbers get wired if more than like 100Trillion :confused:

well i got another system like that which turns out to be much better

	local Digits = {
		"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 function Abrieviate(val)
	for i=1, #Digits do
		if tonumber(val) < 10^(i*3) then
			return math.floor(val/((10^((i-1)*3))/100))/(100)..Digits[i]
		end
	end
end