counter bounce

I am trying to get a counter to increase to 420 then when it hits 420 decrease to 0, i have tried using the following

boolean bounce = false;

void count(){
count_swipe ++;
  
    if (count_swipe == 420){
  bounce = true;
    };

if (bounce){
  count_swipe --;
};

}

obviously this will only work when count_swipe == 420, which will be for a split second, there;s obviously a way of doing this but i've got a mental block so any help would be appreciated, thanks :slight_smile:

could this do why you want?

void count()
{
  count_swipe ++;
  if (count_swipe == 420)
  {
    bounce = true;
    count_swipe = 0;
  }
}