So I basically want to make a number formatter that formats differently: if the player has 100 million cash, it should not have a decimal and should look like “100M”; if the player has 10 million cash, it should have one decimal place if the decimal is not zero and should look like “10M(10,000,001)”, or "72.9M(72,947,199); if the player has less than 10 million cash and more than a million, it should have two decimal places or less if the values of the decimal is 0, and it should look like this: “1.8M(1,808,277)”, “1.09M(1,092,746)”, “3.71M(3,719,272)”, etc. (I picked the numbers randomly for the example)
This is the furthest I have gotten into:
local player = game.Players.LocalPlayer
local value = player:WaitForChild("leaderstats"):WaitForChild("Coins")
local Abbreviations = {
"";
"K";
"M";
"B";
"T";
}
local function AbbreviateNumber(Number)
for i = 1, #Abbreviations do
if Number < 10 ^ (i * 3) then
if Abbreviations[i] == "∞" then
return "∞"
else
return math.floor(Number / ((10 ^ ((i-1) * 3)) / 100)) / (100) .. Abbreviations[i]
end
elseif tostring(Number) == "inf" then
return "∞"
end
end
end
script.Parent.Text = AbbreviateNumber(value.Value)
value.Changed:Connect(function()
script.Parent.Text = AbbreviateNumber(value.Value)
end)
and does not get what I want. Any help appreciated.