I'm trying to make a script that can exceed the default values of a ROBLOX leaderboard, it was successful until I tried to add quadrillions, I know it's possible because I've seen games do it but every time I use the following script I get the value (only when it gets to quadrillions)
1e+.0k
This is the script: (any help is appreciated)
function ConvertShort(num, cool) local x = tostring(num) if #x >= 16 then local important = (#x - 15) cool.Value = x:sub(0,(important)).."."..(x:sub(#x-13,(#x-13))).."qd" elseif #x >= 13 then local important = (#x-12) cool.Value = x:sub(0,(important)).."."..(x:sub(#x-10,(#x-10))).."T" elseif #x>= 10 then local important = (#x - 9) cool.Value = x:sub(0,(important)).."."..(x:sub(#x-7,(#x-7))).."B" elseif #x >= 7 then local important = (#x-6) cool.Value = x:sub(0,(important)).."."..(x:sub(#x-5,(#x-5))).."M" elseif #x >= 4 then cool.Value = x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."k" end end game.Players.PlayerAdded:connect(function(plr) local cash = Instance.new("StringValue", plr) cash.Name = "cash" cash.Value = "0" cash.Changed:connect(function() ConvertShort(tonumber(cash.Value), cash) end) end)
local letters = { "K", "M", "B", "T", "QD", "QN", "SX", "SP", "O", "NO", "DEC", "UND", "DUOD", "TRED", "QUATD", "QND", "SXD", "SPD", "OD", "NOVD", -- I really doubt somebody will get more than a novemdecillion --put more here } local nums = {} for q=1,#letters do local dig = (q*3)+1 --digits local letter = 1*(10^(dig-1)) --for dividing purposes table.insert(nums,#nums+1,letter) --insert end function shorten(num) local len = math.ceil(math.log10(num + .5)) --get the digits if len>=4 then --check if it's ok to shorten for q=1,#letters do local dig = (q*3)+1 --smallest number of digits the letter is if len <= dig+2 then --check if this digit works local toDo = math.floor(num/nums[q]) --the dividing number local newNum = toDo..letters[q] --the new num return newNum --return it end end end end print(shorten(1789000000000000000))--it returns the shortened num