Rotation wont freeze

public Transform rotate;
public Rigidbody rb;

    void Update()
    {
        if (rotate.transform.rotation.x == 50)
        {
            rb.constraints = RigidbodyConstraints.FreezeRotationX;
        }
        if (rotate.transform.rotation.x == -50)
        {
            rb.constraints = RigidbodyConstraints.FreezeRotationX;
        }
        if (rotate.transform.rotation.z == 50)
        {
            rb.constraints = RigidbodyConstraints.FreezeRotationZ;
            Debug.Log("FreezeZ");
        }
        if (rotate.transform.rotation.z == -50)
        {
            rb.constraints = RigidbodyConstraints.FreezeRotationZ;
            Debug.Log("-FreezeZ");
        }
    }

This is probably happening because your player is rotating to quickily to detect when it’s eqeul to 50. Instead of ==, use =>.
Example:
if (rotate.transform.rotation.x >= 50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationX;
}
if (rotate.transform.rotation.x <=-50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationX;
}
if (rotate.transform.rotation.z >= 50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationZ;
Debug.Log(“FreezeZ”);
}
if (rotate.transform.rotation.z <=-50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationZ;
Debug.Log(“-FreezeZ”);
}