if ( digitalRead(. . .) == HIGH ) not triggering?

Hi I’m trying to program a set of traffic lights but my if statement isn’t working. I found how to use if digitalRead from here but it’s probably taken out of context. All the variables and digitalWrites tod what they’re supposed to do. I even asked my fellow classmates for help but they couldn’t provide anything. I’m wondering if I have to rebuild everything or not.
Here’s the arduino setup and code
I use Tinkercad’s Arduino Uno R3 simulation so I don’t know if this too could be a bug in the simulation.

EDIT: traffic lights not stop signs dumb me

//Variabelen van groepen leds
//groep1
int g1 = 11; //g = groen
int o1 = 12; //o = oranje
int r1 = 13; //r = rood
//groep2
int g2 = 8;
int o2 = 9;
int r2 = 10;
//groep3
int g3 = 5;
int o3 = 6;
int r3 = 7;



void setup()
{
  //Groep 1
  pinMode(g1, OUTPUT);	//Groen
  pinMode(o1, OUTPUT);	//Oranje
  pinMode(r1, OUTPUT);	//Rood
  
  //Groep 2
  pinMode(g2, OUTPUT);	//Groen
  pinMode(o2, OUTPUT);	//Oranje
  pinMode(r2, OUTPUT);	//Rood
  
  //Groep 3
  pinMode(g3, OUTPUT);	//Groen
  pinMode(o3, OUTPUT);	//Oranje
  pinMode(r3, OUTPUT);	//Rood
  
  
}


void loop()
{
  digitalWrite(r1, HIGH);
  delay(1000);
  digitalWrite(r1, LOW);
  delay(1000);
  
  digitalWrite(o1, HIGH);
  delay(1000); 
  digitalWrite(o1, LOW);
  delay(1000);
  
  digitalWrite(g1, HIGH);
  delay(1000); 
  digitalWrite(g1, LOW);
  delay(1000); 
  
 if( digitalRead(g1) == HIGH ){
  	digitalWrite(r2, HIGH);
  	digitalWrite(r3, HIGH);
 }
  
}
  delay(1000);
  digitalWrite(g1, LOW);  //set g1 LOW
  delay(1000);
  if ( digitalRead(g1) == HIGH )  //test if g1 is HIGH
  {

Question : how could g1 be HIGH when you just set it LOW ?

The MicroController Execute the Program from top to bottom which means you have rewrite your code like this

digitalWrite(g1, HIGH);
delay(1000);
if( digitalRead(g1) == HIGH ){
digitalWrite(r2, HIGH);
digitalWrite(r3, HIGH);
}

digitalWrite(g1, LOW); //before setting (g1,LOW)
delay(1000);

}
then only your if statement will work.

then only your if statement will work.

But in this case you don’t need an if statement at all. So you can just remove it as it dose nothing.

Ah okay I understand now thank you guys a lot I didn't know that its behavior ran like a script, a massive oversight from my part
I did this and it works now as intended

 digitalWrite(g1, HIGH); 
  if( digitalRead(g1) == HIGH ){
  	digitalWrite(r2, HIGH);
  	digitalWrite(r3, HIGH);
    delay(1000);
  
  } 
  
  digitalWrite(g1, LOW); 
  if ( digitalRead(g1) == LOW ) {
    digitalWrite(r2, LOW);
  	digitalWrite(r3, LOW);
    delay(1000); 
  }
  
  digitalWrite(g1, LOW);

thanks again!

digitalWrite(g1, HIGH); 
  if( digitalRead(g1) == HIGH ){

Again, you just set it HIGH.
How is it going to be anything but HIGH?

How is it going to be anything but HIGH?

Precisely.

Why do you think you need an 'if' statement? You already know the logic level on that pin.

I didn't know that its behavior ran like a script

As a point of interest how did you think it ran?