V5 coding

One of my teams is having problems with combining their autonomous code and their driver control code into the comp template. they work separately but not together. If they push a button for the lift to go to a set height and them back down to 0 it works as a stand alone code but when the add it to the comp template it no longer works.
Button and Manual Code.vex (12.5 KB)

I see some really questionable if statements. The problem is you’re controlling the same motors in multiple spots. In general, most of those won’t be a problem, because you probably won’t press both buttons. For example, don’t press L1 and L2 at the same time and that part is OK. But if you code

if ()
if ()

as

if ()
else if ()

you’ll be much better off. Now, the spot that will always get you is that you can never not use the sticks. They always provide some value. So any time you press R1, R2, or X you’re feeding the motors multiple values, those buttons and the sticks. That will mess them up. Try

if ()
else if ()
else if ()
else {
   LeftMotor.spin(vex::directionType::fwd, (Controller1.Axis3.value() + Controller1.Axis4.value()), vex::velocityUnits::pct); 
   RightMotor.spin(vex::directionType::fwd, (Controller1.Axis2.value() - Controller1.Axis1.value()), vex::velocityUnits::pct);
}

That way the sticks are only used if none of the buttons for the same motors are pressed. Similarly, due to that “else” on X, if you’re not pressing X then you’re always braking LiftMotorLeft and LiftMotorRight. If you’re not trying to use those lift motors, no big deal, but the moment you press L1 or L2 without also pressing X, then you’ll feed those motors multiple values. It looks like that “else” is totally misplaced with X.