Problems regarding controlling Servo Motors with two different buttons

Right now on my project I’m trying to give position to an arm with two servo motors and open a valve with a third one. The first button (with 1 written right next to it) is supposed give position to all three servos until the button is released meanwhile the second button (with 2 written right next to it) is supposed to give rotation to first 2 servos and ignore the third completely and until pressed again servos are supposed to keep their positions.
While after some coding “button 1” is working like it is supposed to but “button 2” has problems. I have to press a few times for it to function and even if it does servos try to get back to their original position and move like 5-10 degrees(servos are supposed to get to the rotation 90, after getting there instantly they move minus 5 or 10 degrees then get back to 90 and loop all over) and get back to the position given to them by button 2. This keeps happening on a loop and no matter how much I try to fix it it couldn’t find a way, I’m hoping someone could shine some light on my way. I hope I was able to explain it properly


If anyone’s wandering the code is here

#include<Servo.h>
Servo Flamer;
Servo Rot1;
Servo Rot2;
#define Buton 10
#define Buton2 3
int state = 0;
int old = 0;
int buttonPoll = 0;
int buttonState = 0;

void setup()
{
  pinMode(Buton2, INPUT);
  Flamer.attach(4);
  Rot1.attach(5);
  Rot2.attach(6);
}

void loop()
{
   //Flamer Rotation
   buttonPoll = digitalRead(Buton2);
  if(buttonPoll == 1){
    buttonPoll = digitalRead(Buton);
    if(buttonPoll == 0)
    delay(50);
    buttonPoll = digitalRead(Buton2);
    if(buttonPoll == 0){
      buttonPoll = digitalRead(Buton);
      if(buttonPoll == 0)
      state = old + 1;
    }}
    else{
      delay(100);
    }
    switch (state) {
    case 1:
      Rot1.write(90);
      Rot2.write(90);
      old = state;
      break;

      default:
      Rot1.write(0);
      Rot2.write(0);
      old = 0;
      break;
}
    //Flamer Action
  buttonState = digitalRead(Buton);
  Serial.println(buttonState);
  if (buttonState == 1) {
    buttonState = digitalRead(Buton2);
    Serial.println(buttonState);
    if (buttonState == 1);
    Rot1.write(90);
    Rot2.write(90);
    delay(500);
    Flamer.write(50);
  } else {
    Flamer.write(0);
    delay(500);
    Rot1.write(0);
    Rot2.write(0);
  }
  
}

edit: for some reasons the pics I uploaded don’t show up so I have to leave the links here, sorry

https://ibb.co/Wy3BnFJ

This is far too confusing - using the same variable for different buttons and reading the buttons multiple times.

   buttonPoll = digitalRead(Buton2);
  if(buttonPoll == 1){
    buttonPoll = digitalRead(Buton);
    if(buttonPoll == 0)
    delay(50);
    buttonPoll = digitalRead(Buton2);
    if(buttonPoll == 0){
      buttonPoll = digitalRead(Buton);

I reckon it would be impossible to debug.

Make it simple - start like this

buttonPoll = digitalRead(Buton);
button2Poll = digitalRead(Buton2);

and use those two values in whatever IF tests are necessary

For debugging you could print the values of the variables to check what values have been recorded

...R

Ok so I fixed the system via adding new "int"s and attaching them to buttons in different conditions to stop them from doing what they previously did. I’ll try my best to explain what I did;
-So first of all I added two new "int"s for my case they were;

int butonsik = 0;
int FlamerCode = 0;

-If you had followed my code you know there is a seperate part for my quick action code. So the first problem was there was a line of code there that was ordering second action (in my case it’s Flamer Rotation) to get it’s servos back to the original rotation and servos couldnt decide if they needed to go back to their original degree or stay at the current degree told to them by the second action. I told the code to stop ordering to go back to the original degree if the first button was pressed like this;

} else {
    butonsik = digitalRead(Buton2);
    if (butonsik = 0) {
    Flamer.write(0);
    delay(500);
    Rot1.write(0);
    Rot2.write(0);
    }}

-After this my Flamer Servo started acting different and went ahead to fix itself at a 90 degree and when pressed to the first button it was fixing it’s rotation to 50 degrees. So I realized the code had a part where it told servos to go back to their original rotation and this servo wasn’t included so I added the second “int” and told it if the first button was 0 then tell the servo to go back to 0 degree;

   default:
      Rot1.write(0);
      Rot2.write(0);
      FlamerCode = digitalRead(Buton);
      if (FlamerCode == 0) {
      Flamer.write(0);
      }
      old = 0;
      break;

This was how I fixed it I hope this could help someone and even though I couldn’t manage to fix it via Debugging thank you Robin for your helpful comment.

for anyone wandering this is the final code

#include<Servo.h>
Servo Flamer;
Servo Rot1;
Servo Rot2;
#define Buton 10
#define Buton2 3
int state = 0;
int old = 0;
int buttonPoll = 0;
int buttonState = 0;
int butonsik = 0;
int FlamerCode = 0;

void setup()
{
  pinMode[Buton, INPUT];
  pinMode(Buton2, INPUT);
  Flamer.attach(4);
  Rot1.attach(5);
  Rot2.attach(6);
}

void loop()
{
   //Flamer Rotation
   buttonPoll = digitalRead(Buton2);
  if(buttonPoll == 1){
    delay(50);
    buttonPoll = digitalRead(Buton2);
    if(buttonPoll == 0){
      state = old + 1;
    }}
    else{
      delay(100);
    }
    switch (state) {
    case 1:
      Rot1.write(90);
      Rot2.write(90);
      old = state;
      break;

      default:
      Rot1.write(0);
      Rot2.write(0);
      FlamerCode = digitalRead(Buton);
      if (FlamerCode == 0) {
      Flamer.write(0);
      }
      old = 0;
      break;
}
    //Flamer Action
  buttonState = digitalRead(Buton);
  Serial.println(buttonState);
  if (buttonState == 1) {
    
    Rot1.write(90);
    Rot2.write(90);
    delay(500);
    Flamer.write(50);
  } else {
    butonsik = digitalRead(Buton2);
    if (butonsik = 0) {
    Flamer.write(0);
    delay(500);
    Rot1.write(0);
    Rot2.write(0);
    }}
}

if (butonsik = 0) Oops