c# problem with limiting rotation (with rigidbody)

So i have a hover car , i have a box collider , a rigidbody attached to it and a script that controls the hovering physics . I want to prevent the car from flipping over by limiting its rotation on the x and z axis (left y out to allow it to turn) i used the following line of code to clamp its rotation but the rotation seems to be completely frozen . Here’s the code i used : “transform.rotation = Quaternion.Euler(new Vector3 (transform.rotation.x,transform.rotation.y,transform.rotation.z));”

You need to use clamp min and max values and then once it reached the clamping values you need to pass the new rotation back again to the rotation value.