Solenoid only stays on true mode and is not reacting to other buttons

void usercontrol(void) {

//vex::thread n(pusher);

enableDrivePID = false;

// User control code here, inside the loop

while (1) {

float input_h = Controller1.Axis1.value()/12.0;

float input_v = Controller1.Axis2.value()/12.0;

float maxVolt = 12;

float deadzone = 6;



input_h = input_h*(std::abs(input_h) >= deadzone);

input_v = input_v*(std::abs(input_v) >= deadzone);

RightFrntmotor.spin(vex::directionType::rev,(input_h + input_v)*maxVolt, vex::voltageUnits::volt);

RightBckmotor.spin(vex::directionType::rev, (input_h + input_v)*maxVolt, vex::voltageUnits::volt);

LeftFrntmotor.spin(vex::directionType::fwd, (input_h - input_v)*maxVolt, vex::voltageUnits::volt);

LeftBckmotor.spin(vex::directionType::fwd, (input_h - input_v)*maxVolt, vex::voltageUnits::volt);

CallOfDuty.spin(vex::directionType::fwd, -Controller1.ButtonR2.pressing()*12, vex::voltageUnits::volt);

CallOfDuty2.spin(vex::directionType::fwd, -Controller1.ButtonR2.pressing()*12, vex::voltageUnits::volt);

if( Controller1.ButtonL2.pressing() ){

solenoid.set( true );

}if( Controller1.ButtonL1.pressing()){

solenoid.set( false );



Can you please add code tags (```) before and after your code in the post.
Add a closing bracket in-between the solenoid.set(false) and the wait(20,msec) and also add an additional closing bracket after the wait(20,msec)


Try an else or else if statement