note: edited this to explain a bit better
I did this ages ago but I forgot & I've googled and found nothing.
I want my screengui text numbers like this picture below
https://imgur.com/a/DejEK (looks like that but isnt going to be used for leaderboard)
I just want to format my numbers to "1,234" instead of "1234" and use it in a gui with a textlabel. Example:
script.Parent.Text = player:WaitForChild("MyNumbers").Value player:WaitForChild("MyNumbers").Changed:Connect(function() script.Parent.Text = player:WaitForChild("MyNumbers").Value end)
instead of having it displayed as 1234 (which this does) i want to display it as 1,234 (which i cant figure out) if that was my value.
local function AddCommas(Number) if typeof(Number) == "number" then Number = tostring(Number) end local Index = -1 while Index ~= 0 do Number, Index = Number:gsub("^(-?%d+)(%d%d%d)", "%1,%2") end return Number end print(AddCommas(1234))
function comma(amt) local formatted = amt while wait() do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if k == 0 then break end end return formatted end