Need Help Applying a Number Abbreviation Function into a Money Gui

I made a money Gui that displays the amount of currency a player has from leaderstats. Well I ran into a problem where the amount of 0’s gets very high in the bigger numbers. I was wondering if anyone could help me insert this 0 shortner into the currency Gui.

Number to Suffix

local suffixes = {"K", "M", "B", "T", "Q", "Qu", "S", "Se", "O", "N", "D"}

local function toSuffixString(n)
	for i = #suffixes, 1, -1 do
		local v = math.pow(10, i * 3)
		if n >= v then
			return ("%.0f"):format(n / v) .. suffixes[i]
		end
	end
	return tostring(n)
end

Currency Gui

local stats = game.Players.LocalPlayer.leaderstats:FindFirstChild("Coins")

stats.Changed:Connect(function()

script.Parent.Text = stats.Value

end)
1 Like

Just put everything into the same script and call the function on the line

script.Parent.Text = stats.Value

like so:

script.Parent.Text = toSuffixString(stats.Value)
3 Likes

It would help if you actually tried debugging your own code instead of reposting it so many times then and maintaining a single thread. This is something that you could’ve reviewed your own code for.

4 Likes

Please don’t spam the forums with the same thread, In the future post only 1 thread if your still confused after debugging and using other resources such as developer.roblox.com, rblxlua.com, rblxforum.com, Scripting Support - Developer Forum | Roblox other friends from others using the same problem or similar persay, Free Models toolbox. Then post a thread, It’s what I do reduces amount of spam threads being posted & so its not spammed.

1 Like

um just an fyi, rblxlua.com and rblxforum.com are both death, the other best resources are scriptinghelpers.com and hidden-developers

yeah well it could help if people on the forum could actually help. Also I’m not a scripter, I just wrote this script on my own for a game I’m working on. I’m a builder, not that good at debugging.

um just an fyi, scriptinghelpers.com is death, stackoverflow would be better if devforum aint helping.

scriptinghelpers.com and devforum were both made for roblox lua