How to change rotation through script

I want to know how to change an object’s rotation on specific axis through script when it touches the ground because I am working on a flight sim. I know how to chage the rotation of it but I don’t know how to change rotation for only the X and Z axis but keep the rotation of the Y axis the same. I use this code.

function OnCollisionEnter(collision : Collision){

if (collision.gameObject.name == “Terrain”){
transform.rotation = Quaternion.Euler(0,0,0);
}
}

Use something like this:

  var rotationVector = transform.rotation.eulerAngles;
  rotationVector.z = 0;
  transform.rotation = Quaternion.Euler(rotationVector);

function OnCollisionEnter(collision : Collision){

if (collision.gameObject.name == "Terrain"){ transform.rotation = Quaternion.Euler(X,Y,Z); } }

Alternatively, if it is a rigidbody, you can lock certain rotations on the rigidbody settings of the object.