How can i abbreviate the leaderstats?

This Should be 17.2T and not 17,200B.
I can abbreviate everything else but leaderstats.

This is how i abbreviate guis:

``````local AbbreviateNumber = require(game.ReplicatedStorage.AbbreviateNumber)

while (1) do
wait()

script.Parent.Text = number
local text = AbbreviateNumber:Abbreviate(number)
script.Parent.Text = text
end
``````

Thats the Abbreviation script in RS:

``````local AbbreviateNumber = {}

local abbreviations = {
N = 30;
O = 27;
Sp = 24;
Sx = 21;
Qn = 19;
Q = 16;
T = 13;
B = 10;
M = 7;
K = 4
}

function AbbreviateNumber:Abbreviate(number)
local text = tostring(math.floor(number))

local chosenAbbreviation
for abbreviation, digits in pairs(abbreviations) do
if #text >= digits and #text < (digits + 3) then
chosenAbbreviation = abbreviation
break
end
end

if chosenAbbreviation then
local digits = abbreviations[chosenAbbreviation]

local rounded = math.floor(number / 10 ^ (digits - 2)) * 10 ^ (digits - 2)

text = "" .. string.format("%.1f", rounded / 10 ^ (digits - 1)) .. chosenAbbreviation
else
text = "" .. number
end

return text
end

return AbbreviateNumber
``````

I would appreciate any help.

I dont really inow how to script things but I can recommend something

Sorry if it didnt help

Hey there! I have a YouTube video covering this exact question:

I watched that vid, but if your value is 0 its abreviating to 0.00. Idk it looks ugly to me.

Add an edge-case check for when the value is 0?

`if value == 0 then...`

Do something similar to what @Forummer said. Instead have an if statement

``````if stats.Value <= 999 then
format(stat.Value, 0)
else
format(stat.Value, 2)
end
``````

Do i need to use string values to abbreviate leaderstats or can i do it in an another way?

It has to be string values, there is no way to display it otherwise!

Hm alright, but if i do it with strings, how can i change my number values to string values?