Leaderstat abbreviation only goes up to 10.0T

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? My leaderstat going higher than 10 trillion.

  2. What is the issue? The issue is that my abbreviations only go up to 10.0T

  3. What solutions have you tried so far? I have looked over the script and it looks good

local PlayerData = game.ServerStorage.PlayerData
	local ChosenAbbre
	local ChosenAbbre2
	local Abbre = {
		K = 4,
		M = 7,
		B = 10,
		T = 13,
		QD = 16,
		QN = 19
	}

while wait() do
		local TimeText = tostring(math.floor(DataTime.Value))
		
		for abbreviation, digits in pairs(Abbre) do
			if #TimeText >= digits and #TimeText < (digits + 3) then
				ChosenAbbre = abbreviation
				break
			end
		end
		
		if ChosenAbbre ~= nil then
			local digits = Abbre[ChosenAbbre]
			local rounded = math.floor(DataTime.Value / 10 ^ (digits - 2)) * 10 ^ (digits - 2)
			Time.Value = string.format("%.1f", rounded / 10 ^ (digits - 1)) .. ChosenAbbre
		else
			Time.Value = DataTime.Value
		end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Well, the value is a NumberValue, not a StringValue so you can’t add letters to the end, right? Correct me if I’m wrong.

Its a string value not a number value, the real values r in player data

2 Likes

tostring converts the value in the scientific notation for values over 13 digits.
Use ("%.0f"):format(value) instead.
Or you could use logarithms to determine the size then divide by 1000 power of that value trauncated (math.floor(math.log(value, 1000)))

I got it to work, but it skips the quadrillion and says 0.2 Qn. Also, I think if you do

".0f"

it will not make a decimal

What do you mean by not make a decimal? “%.0f” gets the integral value of a double without converting it to scientific notation as opposed to tostring.

What’s the script that you’ve got it to work but skips quadrillion and what value did you input?

I fixed it btw, all I did was if I player has more than 100T It will say 100.0T+

it was a simple mistake