stop rotation while climbing

I create a character the climb a ladder but i want that he not rotation while climb a ladder.
this is my code so far

var wastegenladder = tegenladder;

if (tegenladder){
    	moveDirection = Vector3(richtingladder,0,0);
    	tegenladder = false;
    	if (Input.GetButton("k")){
    		moveDirection.y += 100.0 * Time.deltaTime;
    		      totalAmtMoved += amtToMove;
    	}
    }
    
    else{
    	moveDirection.y -= gravity * Time.deltaTime;	
    }
    
    		var isbenedenladder = tegenladder;
	    	if (Input.GetButton("l")){
    		moveDirection.y += -100.0 * Time.deltaTime;
    	}

Just like aldonaletto said, this piece of code doesn’t rotate anything. But some other piece of code does. You need to put that piece of code in the if() statement:

if (!character is climbing)
{
  rotation code;
}

Then, whenever your character starts climbing, set the “character is climbing” flag to true. When it leaves the ladder, set it to false. Note the exclamation mark. That’s a negation operator (and the reason why the “character is climbing” being false will cause the code to be executed, rather than skipped).