I have it to where I crouch and I want it to where the game knows if the player/camera is under an object so the player does not go back up and instead stays crouched.
You can do this similarly to how you do an “on the ground” check. If a Raycast in the up direction hits something close enough then stay in the crouched position.
You could create a trigger collider which checks the area you need to check. And in OnTriggerStay() you just check if there are objects which make you crouch.