:I'm making a clicker game where you make in-game currency, and the numbers will be getting quite high, in the billions or so. Is there any way I could use symbols to account for some of the numbers in order to make them more readable? For instance, if we had 21,500,000,000 (21.5 Billion), it would say something like 21.5B? I don't have much experience with getting specific characters in values and such so how would this be achieved?
✓ ANSWER ACCEPTED
How would I make these large numbers easier to read?
1 answer
✓ Accepted answer
I just found this. Not sure if it works.
function ConvertShort(Filter_Num)
local x = tostring(Filter_Num) -- This is the number you want changed
if #x>=10 then
local important = (#x-9)
return x:sub(0,(important)).."."..(x:sub(#x-7,(#x-7))).."B+"
elseif #x>= 7 then
local important = (#x-6)
return x:sub(0,(important)).."."..(x:sub(#x-5,(#x-5))).."M+"
elseif #x>=4 then
return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
else
return Filter_Num
end
end
To use this, just put this anywhere below the function in your script when you need it. It makes a variable with the new form.
local ShortCash = ConvertShort(Your number goes here)
This discussion is preserved as it was. New answers, comments, and votes are closed.

10 comments
Thanks, but how exactly could I use this in my script? It looks fairly confusing and I'm not sure what to change to make it compatible.
Does that help?
I'll try it real quick, just a sec...
I tried it and it worked to some extent, but when I put in the integer I mentioned earlier (21.5B), it printed it as 21.0B, so it isn't reading the decimal correctly.
Did you put it in like 21500000000?
Yes, I put in that number, for some reason the script isn't reading the decimal correctly.
Im doing two extra lines of code at the end: One to call the function and the other to print the simplified number. Neither of them are the issue as far as I know.
I just did some fiddling around and figured out if I try doing an integer in the millions or thousands the decimal prints fine, so somewhere in the beginning of the function there's an error
Finally figured out the issue, the 7's in line 5 were supposed to be 8's, as soon as I did this the decimals worked fine. Thanks for the base script
Sweet! Glad it worked. Have a good day :)