How can I fix crouching issue?,I have problems with crouching

If my player goes under something while crouching and I release the crouch key, my player gets blocked into the wall. I want my player not to stand up if something is above him. Please help!

Hello.

then you need some kind of “detection object”. For example, an empty object child of the player with atrigger collider, over his head

Then a simple script for this detector that is alwys cheking (with OnTriggerStay) if there is some object over your head. IF detects n object and you are crouch, dont let the player stand again, until the script detects nothing.

Do some tests, look for tutorials, etc…!
Bye & Good luck!