Getting Cash displayer to shrink numbers down

I am currently working on my game and everything has gone very smoothly through one day. There is one thing that I can not figure out. That is how to make this look cleaner.

How could I make the script to when it reaches 1900 say 1,900 instead of 19000 or when it gets to 322188 say 322,188 instead.

And for a million say 1Mil and stuff like that.

Here is the current script:

local plr = game.Players.LocalPlayer
local RS = game:GetService("RunService")
local leaderstats = plr:WaitForChild("Values")
local parent = script.Parent

local c
c = RS.RenderStepped:Connect(function()
	wait()
	parent.Text = "$"..leaderstats:WaitForChild("Cash").Value
end)

Thank You

For the commas, there’s already a topic on that
How would i make a large number have commas? - Help and Feedback / Scripting Support - DevForum | Roblox

There’s also a module for abbreviation
[OPEN SOURCE] [N2Abbreviate] Advanced Number Abbreviate Module (VERY SIMPLE TO USE) - Resources / Community Resources - DevForum | Roblox

1 Like

This may be a stupid question but for the commas how would I incorporate that into my script?

local plr = game.Players.LocalPlayer
local RS = game:GetService("RunService")
local leaderstats = plr:WaitForChild("Values")
local parent = script.Parent

function comma_value(amount)
  local formatted = amount
  while true do  
    formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
    if (k==0) then
      break
    end
  end
  return formatted
end

local c
c = RS.RenderStepped:Connect(function()
	wait()
	parent.Text = "$"..comma_value(leaderstats:WaitForChild("Cash").Value)
end)
1 Like

Why don’t you just use the module, it’s amazing really
EDIT: didnt mean to reply to you sorry

2 Likes
local N2Abbreviate = require(game:GetService("ReplicatedStorage").N2Abbreviate_Module)

print(N2Abbreviate.Convert(numberHere,"Advanced"))

just remember to get the module, and it’s as easy as that.

1 Like

I will give both a try and see which one I like better.

You could use both, like if the number is a million it’s 1M but could be like 1,000 if it’s one thousand

1 Like

The one I sent takes care of the commas and the shortening not to try and be better or anything. (The commas come out as dots btw)

1 Like

Yes
sdlfjksdjklsdklsdfjklsdfkl

2 Likes