so im trying to make a game that if you have a 1,000 coins it will be replaced to 1K coins
You will have to do something like this:
local coins = 8985923 local simplifyCoins = 0 if coins > 999999 then simplifyCoins = coins / 1000000 -- coins above 999,999 will now show up in the format: 5.5 simplifyCoins = math.floor(simplifyCoins * 100)/100 --rounds number down to 2 decimal places simplifyCoins = tostring(simplifyCoins) -- turn it into a string print(simplifyCoins) print(simplifyCoins.."M") elseif coins > 999 then simplifyCoins = coins / 1000 --coins above 999 will now show up in the format: 5.5 simplifyCoins = math.floor(simplifyCoins * 100)/100 --rounds number to 2 decimal places simplifyCoins = tostring(simplifyCoins) -- turn it into a string print(simplifyCoins.."K") end
Prints
--8.98 --8.98M
basically you just check to see how high coins is, then divide it by whatever place it falls on, then concatenate an "M" or "K".
[EDIT] I made it round down 2 decimal places to make it easier to read for the larger numbers. Also,I would put the repeated code inside of a function that is called within the if statements to avoid repeating the same code (that would be a lot of wasted lines if you went up to quintillions)