How do i make a cool money display gui

hhello i want to make a script that turns the money into a value like this:
25002,500
i made something similar but it dosen’t work good it reverse the output:
2500250,0

here is the code:

local ABX = game.Players.LocalPlayer.ABX

local First = false

function round(n, decimals) decimals = decimals or 0 return math.floor(n * 10^decimals) / 10^decimals end

function update()
	local val = tostring(ABX.Value)
	local s = ""

	for i = 1, round(string.len(val)) do
		s = s .. string.sub(val, 3 * (i - 1) + 1, 3 * i)

		if string.len(string.sub(val, 3 * (i - 1) + 1, 3 * i)) >= 3 and string.len(val) > 3 * i then
			s = s .. ","
		end
	end

	script.Parent.Text = s
end

update()

ABX.Changed:Connect(function()
	update()
end)

thank you for reading!

1 Like
function reformatint(integer)
    for i = 1, math.floor((string.len(integer)-1) / 3) do
        integer = string.sub(integer, 1, -3*i-i) ..
                  ',' ..
                  string.sub(integer, -3*i-i+1)
    end
    return integer
end

1 Like

thank you so much for this code!