Number Shortening?

Example
Player1 has over 50M cash, but they can hardly see it on the GUI because the text was too long, thus making it smaller.

50000000 Cash → 50M Cash (On the label)

How would I accomplish this?

My current script
local l = game.Players.LocalPlayer.leaderstats

while wait() do
	script.Parent.Cash.Text = l.Cash.Value.." Cash"
end

All help appreciated!

1 Like

It would be simpler to understand if you watch this video.

2 Likes

Count the amount of "0"s in the number, then for every # of zero, you add a postfix

You can do something like this:

local value = 5000000
local display = value
if #tostring(value) > 5 then
	display = value / 1000000 .. "M"
end
print(display)

EDIT: Oops old post lol. Someone before me bumped it.