Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I abbreviate large IntValues?

Asked by
Retroc 35
9 years ago

In tycoon game, the player's cash values are stored in game.ServerStorage.MoneyStorage.(All of the player's name are IntValue and the value is there money). I wrote this script to try and abbreviate it but it doesn't seem to be working, could someone help out? Nothing is underlined or anything and the output window isn't showing anything.

wait(2)

function Convert(num)
local x = tostring(num)
if #x>=13 then
local num1 = (#x-12)
return x:sub(0,(num1)).."."..(x:sub(#x-10,(#x-10))).."Q+" --Quadrillion
elseif #x>=10 then
    local num1 = (#x-9)
    return x:sub(0,(num1)).."."..(x:sub(#x-7,(#x-7))).."B+" --Billion
elseif #x>= 7 then
 local num1 = (#x-6)
 return x:sub(0,(num1)).."."..(x:sub(#x-5,(#x-5))).."M+" --Million
elseif #x>=4 then
    return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+" --Thousand
else
return num
end
end

local number = game.ServerStorage.MoneyStorage:GetChildren()

number.Value.Changed:connect(function()
    number.Value = Convert(number.Value)
end)

0
I answered your question already! connor12260311 383 — 9y
0
go back to your old version of this question for a legit answer connor12260311 383 — 9y

Answer this question