[Resolved] How to display score with commas?

I need to display the player’s score with commas in the appropriate spots (for example, “2,000”). How do I do that?

Thanks! [import]uid: 135391 topic_id: 24602 reply_id: 324602[/import]

[lua]function commas (num)
assert (type (num) == “number” or
type (num) == “string”)

local result = “”

– split number into 3 parts, eg. -1234.545e22
– sign = + or -
– before = 1234
– after = .545e22

local sign, before, after =
string.match (tostring (num), “^([%+%-]?)(%d*)(%.?.*)$”)

– pull out batches of 3 digits from the end, put a comma before them

while string.len (before) > 3 do
result = “,” … string.sub (before, -3, -1) … result
before = string.sub (before, 1, -4) – remove last 3 digits
end – while

– we want the original sign, any left-over digits, the comma part,
– and the stuff after the decimal point, if any
return sign … before … result … after

end – function commas[/lua] [import]uid: 7177 topic_id: 24602 reply_id: 99618[/import]