[AS2/3] Platform Slopes

Hello, I am trying to make a code for platform slopes…

Here is what I have:

//Slope Amendment
        
    if (_root.slope.hitTest(_x+1+8+6,_y-10,true) || 
        _root.slope.hitTest(_x-1-8-6,_y-10,true)){falling = false; airtime = 0;}
    
    looptimes = 0; //with loop breaker
    if (!_root.slope.hitTest(_x+1+8+6+10,_y-70,true)){
            while (_root.slope.hitTest(_x+1+8+6,_y-10-1,true)){_y -= 1;
            looptimes+=1; if (looptimes>maxloop){breakcode=true; break;}}
    } else rightspeed=0;
    trace(looptimes);
    looptimes = 0;
    if (!_root.slope.hitTest(_x-1-8-6-10,_y-70,true)){
        while (_root.slope.hitTest(_x-1-8-6,_y-10-1,true)){_y -= 1;
            looptimes+=1; if (looptimes>maxloop){breakcode=true; break;}}
    } else leftspeed=0;

You can move up and down the slopes just fine, but the problem is (when you are about halfway up a slope) you can’t jump/jump slightly into the air.

The code works fine if you swap out the while loops for if statements, but obviously then the player will rise from the slopes and it would just look stupid.

Any ideas?
Thanks!

-Nick