Abbreviation with gui problem

function abbreviateNumber (n)
	
	local s = tostring(math.floor(n))
	return string.sub(s, 1, ((#s - 1) % 3) + 1) .. ({"", "K", "M", "B", "T", "QA", "QI", "SX", "SP", "OC", "NO", "DC", "UD", "DD", "TD", "QAD", "QID", "SXD", "SPD", "OCD", "NOD", "VG", "UVG"})[math.floor((#s - 1) / 3) + 1]
end

script.Parent.Text= "Coins = ".. abbreviateNumber(game.Players.LocalPlayer:WaitForChild("leaderstats"):FindFirstChild("Coins").Value)
	

I am trying to show the coins a player has but abbreviating it but it shows nothing
there are no errors

2 Likes

Is Coins a String Value or a Int/Number Value?

The coins are a int and it still dosesnt work

I think It should be a string value since abbreviateNumber() is returning a string.

Edit: Also dosn’t roblox abbreviate this stuff for you?

try and change it to
local suffixes = {'','K','M','B','T','qd','Qn','sx','Sp','O','N','de','Ud','DD','tdD','qdD','QnD','sxD','SpD','OcD','NvD','Vgn','UVg','DVg','TVg','qtV','QnV','SeV','SPG','OVG','NVG','TGN','UTG','DTG','tsTG','qtTG','QnTG','ssTG','SpTG','OcTG','NoAG','UnAG','DuAG','TeAG','QdAG','QnAG','SxAG','SpAG','OcAG','NvAG','CT'} local function format(val) for i=1, #suffixes do if tonumber(val) < 10^(i*3) then return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i] end end end game.Players.LocalPlayer:WaitForChild("leaderstats"):FindFirstChild("Coins").Changed:Connect(function(value) script.Parent.Text = "Coins: "..format(value) end)

2 Likes

Thank you it works now :)))) Its gonna help me very much

1 Like