I’m making a simulator-type game, and I want to make the “Cash” fit in the leader stats so I thought of turning 100,000 to 100k. But I’m not sure how, does anyone have an example script or a script for it?
Sometimes this module works for me:
[ModuleScript Example:]
local module = {}
function module:AbbreviateNumber(number)
local val = tostring(math.floor(number))
local valn = math.floor(tonumber(number))
if valn >= 1000 and valn <= 10000 then
val = string.sub(val, 1, 1) .. "." .. string.sub(val, 2, 1) .. "K"
end
if valn >= 10000 and valn <= 100000 then
val = string.sub(val, 1, 2) .. "." .. string.sub(val, 3,2) .. "K"
end
if valn >= 100000 and valn <= 1000000 then
val = string.sub(val, 1, 3) .. "." .. string.sub(val, 4, 4) .. "K"
end
if valn >= 1000000 and valn <= 10000000 then
val = string.sub(val, 1, 1) .. "." .. string.sub(val, 2, 2) .. "M"
end
if valn >= 10000000 and valn <= 100000000 then
val = string.sub(val, 1, 2) .. "," .. string.sub(val, 3 ,3) .. "M"
end
return val
end
return module
Its an example, but for simulators I think it should work
Thanks I found a solution but thanks for the script!