fade down, STOP. fade up, STOP.

if (sensorVal <=38 && sensorVal >=25){

So are testing to be in the range from 25 to 38. Looks odd written that way.

if(sensorVal < 24){
 for (int x = 255; x <= 0; x --) {  //<< need a bracket here
 if (sensorVal < threshold){      // bail out on sensor detect  << this is guaranteed to happen due to getting here by sensorVal <24 above
       x =0;
       break;  // this is not needed
}
delay(30);

  
}}

Simplify this to:

if(sensorVal < 24){
       x =0;
}
delay(30);