Simple Counter Issue

I have a simple sketch that I want to light an LED strip when a sensor is activated. This first time the sensor is activated, I want the lights to turn red, the next time green and the next time blue. I created a simple counter using the following code, but it's not working right. At the beginning of the loop, I check to see if the counter is equal to 4 and if it is, I set it back down to 0.

When the counter equals 1 - I want the "red" code loop to play, when the counter equals 2, i want the green loop to play, etc...

I thought my logic below was sound, but it just cycles through all the loops when the sensor is activated. I printed the value of the counter to try and troubleshoot, but it only prints 0.

void loop() 

{
  if(digitalRead(sensor)==HIGH)
   
  {
    if (counter=4) {
      counter =0;
    }
     Serial.println(counter);
    counter = counter++;
    digitalWrite(ledPin, HIGH);
    strip.setBrightness(50);

  if (counter=1){
    red(); }

     if (counter=2){
    green(); }

    if (counter=3){
    blue(); }
 

    
  }

Any help would be appreciated.

...
  if (counter=1){
...
     if (counter=2){
...
    if (counter=3){
...

Trifecta of oops.

...
    if (counter=4) {
...

With a bonus.

Hint: this is correct.

if(digitalRead(sensor)==HIGH)

But even with the = vs == fixes, won't it need to look at the sensor having just gone high, not being high, ala the StateChangeDetection example?

Yes.

counter = counter++;

should be

counter++;

Thanks the == did the trick, I wasn't aware of the difference between = and == but a quick Google solved that.

Did you fix the

counter = counter++;

What colour do you want when the counter is 0?