Hey! I made this basic module to make numbers more ‘readable’, it doesn’t support numbers bigger than 1B (1000000000) and less than 1K (1000)
Get the Module here: https://create.roblox.com/marketplace/asset/12624920410/fixnum or fixnum - Roblox
Module source: (ModuleScript)
local module = {}
module.Get = function(num: number)
if num <= 1000 or num >= 1000000000 then
return tostring(num)
end
if num >= 1000 and num < 10000 then
local str = tostring(num)
if tonumber(str:sub(2,2)) >= 1 then
return str:sub(1,1).."."..str:sub(2,2).."K+"
end
if num == 1000 then
return str:sub(1,1).."K"
end
return str:sub(1,1).."K+"
elseif num >= 10000 and num < 100000 then
local str = tostring(num)
if tonumber(str:sub(3,3)) >= 1 then
return str:sub(1,2).."."..str:sub(3,3).."K+"
end
if num == 10000 then
return str:sub(1,2).."K"
end
return str:sub(1,2).."K+"
elseif num >= 100000 and num < 1000000 then
local str = tostring(num)
if tonumber(str:sub(4,4)) >= 1 then
return str:sub(1,3).."."..str:sub(4,4).."K+"
end
if num == 100000 then
return str:sub(1,3).."K"
end
return str:sub(1,3).."K+"
elseif num >= 1000000 and num < 10000000 then
local str = tostring(num)
if tonumber(str:sub(2,2)) >= 1 and tonumber(str:sub(3,3)) == 0 then
return str:sub(1,1).."."..str:sub(2,2).."M+"
end
if tonumber(str:sub(2,2)) >= 1 and tonumber(str:sub(3,3)) >= 1 then
return str:sub(1,1).."."..str:sub(2,3).."M+"
end
if num == 1000000 then
return str:sub(1,1).."M"
end
return str:sub(1,1).."M+"
elseif num >= 10000000 and num < 100000000 then
local str = tostring(num)
if tonumber(str:sub(3,3)) >= 1 and tonumber(str:sub(4,4)) == 0 then
return str:sub(1,2).."."..str:sub(3,3).."M+"
end
if tonumber(str:sub(3,3)) >= 1 and tonumber(str:sub(4,4)) >= 1 then
return str:sub(1,2).."."..str:sub(3,4).."M+"
end
if num == 10000000 then
return str:sub(1,2).."M"
end
return str:sub(1,2).."M+"
elseif num >= 100000000 and num < 1000000000 then
local str = tostring(num)
if tonumber(str:sub(4,4)) >= 1 and tonumber(str:sub(5,5)) == 0 then
return str:sub(1,3).."."..str:sub(4,4).."M+"
end
if tonumber(str:sub(4,4)) >= 1 and tonumber(str:sub(5,5)) >= 1 then
return str:sub(1,3).."."..str:sub(4,5).."M+"
end
if num == 100000000 then
return str:sub(1,3).."M"
end
return str:sub(1,3).."M+"
elseif num >= 1000000000 and num < 10000000000 then
local str = tostring(num)
if tonumber(str:sub(5,5)) >= 1 and tonumber(str:sub(6,6)) == 0 then
return str:sub(1,1).."."..str:sub(5,5).."B+"
end
if tonumber(str:sub(5,5)) >= 1 and tonumber(str:sub(6,6)) >= 1 then
return str:sub(1,1).."."..str:sub(5,6).."B+"
end
if num == 1000000000 then
return str:sub(1,1).."B"
end
return str:sub(1,1).."B+"
end
end
return module
Example usage: (LocalScript or Script)
local module = require(game:GetService("ReplicatedStorage").fixnum) -- Module path OR require(12624920410) to require the module model
print(module.Get(1000))
print(module.Get(1200))
print(module.Get(10000))
print(module.Get(12040))
print(module.Get(1000000))
print(module.Get(1204000))
print(module.Get(10000000))
print(module.Get(12340000))
print(module.Get(100000000))
print(module.Get(120400000))
print(module.Get(1000000000))
print(module.Get(1204500000))
--[[
Output:
1K
1.2K+
10K
12K+
1M
1.2M+
10M
12.34M+
100M
120.4M+
1B
1.5B+
]]
Note: This code may not be fully optimized, this was rushed and made in less than 30 minutes. I dont mind if you want to optimize the code better, you can use it for anything you wish to.