How do i add a thousand separator to my text?

So i’m making a little clicker game to test wick and i was wondering if there is a way to add a thousand separator for the score/points etc… so that instead of 1000 to be 1,000.

I had to look online for this, here’s something I found that works:


function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
/* 
Replace project.score with the name of your score, and "text" 
with the name of your text object
*/
text.setText(numberWithCommas(project.score));

Here’s an example:
My Project12-8-2020_8-50-25AM.wick (1.6 KB)

1 Like

Thank you very much :smiley: