I'm having trouble with crouching

You can line cast above the mesh to see iif there is an obstacle. if there is and the character is crounching he should not uncrounch.