Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Number Filtering stops working after 99T?

Number filtering isn't work 100% The problem isn't the NumberValue because the number limit is 99999989999999992000 But now the problem this only get it until 99T+ then it changes to 1e + 014 inside the textlabeL, inside leaderboad it will stay 100000000000. what could be the problem?

Module script: [Module script solved by BlueTaslem only one problem if value is 1 or 0 it breaks]

local module = {
	['Game_Settings'] = {
		['Kortere_Nummers'] = true
	}
	}


function module:ConvertKlein(num)
	{1e36, suffix = "m+"}, -- megiillion
	{1e33, suffix = "d+"}, -- decillion
	{1e30, suffix = "n+"}, -- nonillion
	{1e27, suffix = "o+"}, -- octillion
	{1e24, suffix = "s+"}, -- septillion
	{1e21, suffix = "L+"}, -- lilion
    {1e18, suffix = "Q+"}, -- quintillion
    {1e15, suffix = "q+"}, -- quadrillion
    {1e12, suffix = "T+"}, -- trillion
    {1e9,  suffix = "B+"}, -- billion
    {1e6, suffix = "M+"}, -- million 
}

for _, power in ipairs(suffixes) do
    if num > power[1] then
        return math.floor(num / power[1]) .. power.suffix
    end
end
end

return module

error: attempt to concatenate a nil value

1 comment

0

I'm not a expert in strings. But is the script in the text label a local script?

1 answer

✓ Accepted answer

Don't turn the number into a string and then check its length. That's not what defines a number being more than a trillion.

It's a number, not text. Use things that treat it like a number (e.g., math.floor, /, *, +), not things that treat it like text (e.g., # and :sub)

local MILLION = 1e6
local BILLION = 1e9
local TRILLION = 1e12
local QUADTRILLION = 1e15
local QUINTILLION = 1e18

-- Just truncating, e.g.,
-- 12345678 --> 12M+
if num > QUINTILLION then
	return math.floor(num / QUINTILLION) .. "Q+"
elseif num > QUADRILLION then
	return math.floor(num / QUADRILLION) .. "q+"
elseif num > TRILLION then
	return math.floor(num / TRILLION) .. "T+"
elseif num > BILLION then
	return math.floor(num / BILLION) .. "B+"
elseif num > MILLION then
	return math.floor(num / MILLION) .. "M+",
else
	return tostring(num)
end

For brevity, this could be turned into a loop:

local suffixes = {
	{1e18, suffix = "Q+"},
	{1e15, suffix = "q+"},
	{1e12, suffix = "T+"},
	{1e9,  suffix = "B+"},
	{1e6, suffix = "M+"},
}

for _, power in ipairs(suffixes) do
	if num > power[1] then
		return math.floor(num / power[1]) .. power.suffix
	end
end

You can get another significant digit like this:

local DECIMALS = 1 -- one digit after the `.`

for _, power in ipairs(suffixes) do
	if num > power[1] then
		return math.floor(num / power[1] * 10^DECIMALS)
			/ 10^DECIMALS
			.. power.suffix
	end
end

4 comments

0

This are for the module script right "function module:ConvertKlein(num)" (one of those 3)

0

of course

0

The problem isn't the textlabel but the module script it doesn't work if its 0 value how can I fix this I already tried 0e0 but nothing happens still the same error

1

You of course need to return something if the loop doesn't hit... Just return tostring(num)

This discussion is preserved as it was. New answers, comments, and votes are closed.