Hi I have 2 functions. 1 to add commas after every 3 digits and the other to round off. I’ve done a lot of research, I’ve started experimenting myself, but I’m not getting it done. I hope you can help me. I don’t know how to add 2 functions to a textlabel.
This is my current script that doesn’t work:
local Players = game.Players.LocalPlayer
local Text = script.Parent.Parent.Amount
local numbermine = Players.leaderstats.Energy
function addComma(number)
local left, num, right = string.match(number, '^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end
function round(n)
return math.floor(n + 0.5)
end
numbermine.Changed:Connect(function(val)
Text.Text = addComma and round (tostring(val))
end)