I have a game and I want the number to be 1.5M instead of 1500000. I don't want to put commas in because that maxes out a 1 Quadrillion so I want to use letters after the numbers. If my explaining is horrible, thats what my irl friends say, then I mean just like case clicker
Would this work?
01 | local value = script.Parent.Text |
02 |
03 | function changeNumber(int) |
04 | if tonumber (int) > 1000 then int.Text = 1 K |
05 | --// Other stuff |
06 | end |
07 |
08 | while true do |
09 | changeNumber(value) |
10 | wait( 1 ) |
11 | end |
Tested and functional; Lengthen the shorten function (haha) to add more values, and update "money" with whatever you desire. Shortens to 1 decimal place.
01 | local money = 0 ; -- update this value by whatever means |
02 | local text = script.Parent.Text; |
03 |
04 | local shorten = function (number) |
05 | if (number > 1000 and number < 1000000 ) then |
06 | return tostring (math.floor(number/ 10 ^ 2 )/ 10 ) .. "k" ; |
07 | elseif (number > 1000000 and number < 1000000000 ) then |
08 | return tostring (math.floor(number/ 10 ^ 5 )/ 10 ) .. "m" ; |
09 | elseif (number > 10 ^ 9 and number < 10 ^ 12 ) then |
10 | return tostring (math.floor(number/ 10 ^ 8 )/ 10 ) .. "b" ; |
11 | -- ... update with more ifs here |
12 | end |
13 | end |
14 |
15 | while wait() do |
16 | text = shorten(money); |
17 | end |
You'll need a way to keep track of the actual cash for it wont get lost so just change "Cash" to where you want/are keeping it.
01 | local value = script.Parent.Text |
02 | local Cash = 50012 --Whatever the cash value is |
03 |
04 | function changeNumber(int) |
05 | if tonumber (Cash) > 1000 then |
06 | print ( tostring ( Cash/ 1000 .. "k" )) |
07 | end |
08 | end |
09 |
10 | while true do |
11 | changeNumber(value) |
12 | wait( 1 ) |
13 | end |