Falling through floor when crouching FPS C#,When I crouch my body falls through the floor (FPS)

I have a simple crouch script but my body always slowly falls through the floor after I hold control. I tried using this script: ` if (Input.GetKey(KeyCode.LeftControl))


      transform.position.z += 1

           transform.position.z += 0

but it keeps giving me the error “cannot modify transform.position because it is not a variable”
Any help?
I have colliders and rigidbodies.

You cannot directly modify the value of a component in a Vector3, for example the z component in your transform.position transform.position.z. I assume this is because it is read-only. However, the Vector3 itself, isn’t and so you can set the value of transform.position.z by modifying transform.position as a whole. For example:

transform.position = new Vector3
    transform.position.z + 1


Another thing, if you’re modifying the position of the player when crouching (don’t know why it’s the z position and not the y), you might teleport the player into the ground, and so they may slowly descend to their demise. You might want to modify the scale instead, or the camera position, so the player looks like they are smaller or crouching.