Abbreviation errors

Hello fellow devforum users! I was recently making an abbreviation system for my game and noticed that it doesn’t work one bit. Unfortunately, the output won’t tell me a thing. So, here I am.

this is a local script:

function aberviate(number)
	local abreviations = {
		[3] = "K",
		[6] = "M",
		[9] = "B",
		[12] = "T"
	}
	if number < 1000 then
		return number
	elseif string.find(tostring(number),"e+") then
		local split = string.split(tostring(number),"e+")
		if split[1] and split[2] then
			local power = tonumber(split[2])
			if power then
				local abreviation = power - (power % 3)
				local truepre = tonumber(split[1])
				if truepre then
					local preAb = tostring(truepre * (10^(power-(abreviation)))) .. " "
					return preAb .. abreviations[abreviation]
				end
			else
				return number
			end
		end
	elseif not string.find(tostring(number),"e+") then
		local num = tostring(math.floor(number))
		local length = #num
		local trueLength = #num % 3
		if trueLength == 0 then
			trueLength = 3
		end
		local abreviation = abreviations[length-trueLength]
		if abreviation then
			local startNum = string.sub(num, 1, trueLength) .. "."
			local decimals = string.sub(num, trueLength+1,trueLength+2) .. " "
			if startNum and decimals then
				return startNum .. decimals .. abreviation
			else
				return number
			end
		else
			return number
		end
	end
end

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	script.Parent.Text = aberviate(game.Players.LocalPlayer.leaderstats.Coins.Value)
end)

Hello, I recently helped someone else out with this issue and believe that this post may help:

Everything regarding how it works should be explained there. Let me know if you have any further questions!

Thanks for the help! It is greatly appreciated, now I don’t have to look at 1000000 anymore. I can just see 1M, much better.