Buttons wont work

Hello. I have problem that if one of the buttons is on you swich it to another and it gets low but if you try to swich agian to it you cant because one button wont turn off.

My code:
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int myg = 7;
int mygt = 8;
int L1 = 9;
int L2 = 10;
int sk1 = 0;
int skai = 0;
int state = LOW;
int reading;
int previous = HIGH;
int statee = LOW;
int readingg;
int previous1 = HIGH;
long time = 0;
long debounce = 200;
long debounce1 = 200;
void setup() {
pinMode(myg, INPUT);
pinMode(mygt, INPUT);
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop() {
reading = digitalRead(myg);
readingg = digitalRead(mygt);

if (readingg == HIGH && previous1 == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;
}

if (reading == HIGH && previous == LOW && millis() - time > debounce) {
if (statee == HIGH)
statee = LOW;
else
statee = HIGH;
}
if (state == HIGH)
{
skai ++;
statee = LOW;
digitalWrite(L1, HIGH);
digitalWrite(L2, LOW);
delay(500);
digitalWrite(L1, LOW);
digitalWrite(L2, LOW);
delay(500);

}

if (statee == HIGH)
{
sk1 ++;
state = LOW;
digitalWrite(L2, HIGH);
digitalWrite(L1, LOW);
delay(500);
digitalWrite(L1, LOW);
digitalWrite(L2, LOW);
delay(500);
}
if (sk1 == 100)
{
state = LOW;
statee = LOW;
}
if (skai == 100)
{
state = LOW;
statee = LOW;
}
lcd.setCursor(0, 0);
lcd.println("Team1");
lcd.println(skai);
lcd.setCursor(0, 1);
lcd.println("Team2");
lcd.println(sk1);
previous = reading;
previous1 = readingg;
delay(500);
}

Instead of repeating the same code blocks with different variables, you should use arrays. The value of "long time" never changes and it should be unsigned.

Is this the same problem as One of the buttons wont stay high - Programming Questions - Arduino Forum

UKHeliBob No. I need one button to turn off when other is pressed and other turn off when another is pressed.
Button1 high then button2 low
button2 high then button1 low.
But if i have pressed one of the buttons then it turns off other button but if i try to make another button on button that is on wont turn off.
button1 high then button2 low
but if this one is done "button1 high then button2 low" button2 wont work until I turn off button1.
So how can I use those arrays can you give example or youtube video link?

Danois90 I have thought about that but how can I make something simular to this
Button1 high then button2 low
button2 high then button1 low.

How are the button inputs wired ?

if i have pressed one of the buttons then it turns off other button

You can't turn off a button. You can, however, turn off an LED associated with a button.

I wanted to say that it makes the button state low. I need to make other button state low if other is pressed.

KEMSESTS:
I wanted to say that it makes the button state low. I need to make other button state low if other is pressed.

You are think wrongly about this.

Pressing either button will not change the state of the other one, nor should it. Pressing a button will cause the states of the 2 LEDs to change

Try something like this

const byte buttonPin1 = A1;
const byte buttonPin2 = A2;
const byte ledPin1 = 3;
const byte ledPin2 = 5;
byte currentButton1State;
byte currentButton2State;
byte previousButton1State;
byte previousButton2State;

void setup()
{
  Serial.begin(115200);
  pinMode(buttonPin1, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  digitalWrite(ledPin1, HIGH); //start with led 1 on
  digitalWrite(ledPin2, LOW);  //and led 2 off
}

void loop()
{
  previousButton1State = currentButton1State;
  currentButton1State = digitalRead(buttonPin1);
  previousButton2State = currentButton2State;
  currentButton2State = digitalRead(buttonPin2);
  if ((currentButton1State != previousButton1State) && currentButton1State == LOW || (currentButton2State != previousButton2State) && currentButton2State == LOW)
  {
    digitalWrite(ledPin1, !digitalRead(ledPin1));
    digitalWrite(ledPin2, !digitalRead(ledPin2));
  }
}

So it seams to work ,thanks, but I need buttons to stay on when they are pressed once and then turn off when other is pressed

[rant]PLEASE STOP ASKING FOR THE BUTTONS TO STAY ON[/rant]

It is the LEDs that turn on and off under the control of the program not the buttons

The sample I posted shows how to change the state of both LEDs to the opposite state when either button is pressed. If you want say button 1 to change the state of the LEDs only when LED 1 is on and the same for button 2 and LED 2 only when LED 2 is on then the program can be revised to do it but you must explain exactly what you want the program to do.

Something simular to this.