Motor Not Stopping - VSCode

My motor will not stop unless I press Y, I added Y because the motor will not stop. Can anyone help me figure out why? My function for the motor is below.

void LiftMotor() {
  if (Controller1.ButtonX.pressing()) {
    liftpos = 50;
    liftspeed = liftpos * liftexcel;
    liftMotor.spin(forward, liftspeed, percent);
    liftMotor.setStopping(vex::brakeType::hold);
  }
  else if (Controller1.ButtonB.pressing()) {
    liftpos = -50;
    liftspeed = liftpos * liftexcel;
    liftMotor.spin(forward, liftspeed, percent);
    liftMotor.setStopping(vex::brakeType::hold);
  }
  if (Controller1.ButtonY.pressing()) {
    liftpos = 0;
    liftspeed = liftpos * liftexcel;
    liftMotor.spin(forward, liftspeed, percent);
  }
  if (Controller1.ButtonX.pressing()){
    Brain.Screen.print("True");
  }
}

Do you want your motor to stop when you’re not pressing any buttons? Add an else statement after your else if statement like this:

if (ButtonA.pressing()) {
   liftMotor.spin(forward);
}
else if (ButtonB.pressing()) {
   liftMotor.spin(backward);
} 
else {
   liftMotor.stop();
}

yep that is what I needed thanks! new to coding so thanks for the help!

3 Likes