[SOLVED] Rising counter

Hello there! How would I make it so I have a counter that rises until it reaches a given number?

this.entity.element.text = + 1;

so how would I get it to add 1 constantly

Hi @GraphicBuildGames,

Do you mean like add 1 every frame? If that’s what you want, just move your code over to your script update() method. Most likely you are asking for something else though.

To have it run until it reaches a certain number just add a guard condition:

if(this.entity.element.text < 100){
   this.entity.element.text += 1;
1 Like

it just says 1 and does not go up

I think you want to use += instead of =+, but I’m not sure if that works directly like this.


Good point, I think that will fail, updating my reply too.


it says 0111 and it does it immediately. I want to be able to see it go up.

You probably need to create a variable to keep track of the counter. Then you can apply this variable to your text element.

// initialize 
this.counter = 0;
// update
if (this.counter < 100) {
    this.counter += 1;
    this.entity.element.text = this.counter;

1 Like


1 Like