Locking r-axis during y-axis movement



I would like to know if there is a possibility to block the r-axis rotation during the y-axis movements. The joint4 should remain motionless regardless of the movement of the other axes (as is the case with mouse control) both during manual control and when using blocky or script

Thanks in advance,

Best regards