First Person Controller - Crouch Help - C#

I got a question with a crouching script on the First Person Controller.
So I made this short code and applied it to the controller.

	void Update () {
		if(Input.GetKeyDown(KeyCode.C)){
			transform.localScale = new Vector3 (1,0.5f,1);
		}
		if(Input.GetKeyUp (KeyCode.C)) {
			transform.localScale = new Vector3 (1, 1, 1);
		}
	}

So I have it attached to the First Person Controller and when I play the inspector shows the values work accordingly. When crouched he scales down but when he comes out of crouching he scales back to normal size but just falls through the floor. As he’s falling I keep trying the crouching button to make sure the values still work and they do. The problem to me seems to be outside of the script rather than the code itself. But I could be wrong. Thanks in advance

I am guessing that the collider is being shoved into the ground when it is re-sized. I recommend setting an initial y offset on the collider which is equal to half of the collider height (ex: if height is 2m, then the center y offset should be 1m). This will keep the pivot at the bottom of the collider and prevent the scaling from moving it down.

However, with scales less than 1/2, the collider will begin to move downwards again which must be counteracted with a translation. For this reason, I prefer to adjust both the height and the offset of the collider instead of using the scale.