Need help LED Toggle between red and green!

I have been trying to program a green LED to turn on at the press of a button, and when I press the button again it turns off AND turns ON a Red LED. (Swapping between green and red LEDs being on at the press of a button)

I have been so close to getting this to work but I seriously CANNOT figure it out.
Any help would be greatly appreciated! Thanks

I have tried to keep the code simple but it might have to be changed a lot. I am fairly new to coding so I'm trying to understand what I've been doing wrong.

int GreenLED = 3; 
int RedLED = 4;

int buttonPin = 7;
int toggleState = false; 

void setup() 
{
  Serial.begin(9600);
  pinMode(GreenLED, OUTPUT); 
  pinMode(RedLED, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP); 
}

void loop() // Main loop
{
  if (digitalRead(buttonPin) == false) { 
  toggleState = !toggleState; 
  digitalWrite(GreenLED, toggleState);  
int LEDValue = digitalRead(GreenLED);
  Serial.println(LEDValue);
  if (LEDValue == 1); {
  digitalWrite(RedLED, HIGH);
  delay(50);
  }
  if (LEDValue != 1); {
    digitalWrite(RedLED, LOW);
    delay(50);
  }
  

}

  
  while (digitalRead(buttonPin) == false); {
  delay(50); 

  }
  }

Take a look at the Arduino State Machine example, as that is the basic concept that you need.

File>Examples>Digital>StateChangeDetection

Okay Thanks

You are not debouncing your button, so will toggle an indeterminate number of times on each press.

You CAN do it in code; but its much easier AND better just to add a small capacitor across the button.

Check my page here