How to add 2 functions to a textlabel?

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)

Are you trying to round the number and then add commas?

1 Like

No, I’m trying to do them at the same time.

the and parameter only works on things like if functions, while loops etc. For that you’ll have to combine both functions together.

The way you did it is not gonna work, I could help but I’m still unsure of the execution you’re trying to do

1 Like

The execution I try to do is to make a comma after every 3 digits and at the same time round the number upwards if the numbers of the text change to a decimal number. So for example: 8000.4324885835 becomes 8,000 and 9000.697543 becomes 9,001.

That would basically be

Text.Text = addComma(tostring(round(val)))

It rounds the number first and then passes it to addComma, giving what you want

2 Likes