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)
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)