How to access rotation constraints?

i wanted the rotation constraints to be on when the bool is false, and vice versa. Here’s what i tried:

void Update()
{
    
    if(ExampleBool = false)
    {
        rb.constraints.Rotation.x.enabled = true;
        rb.constraints.Rotation.y.enabled = true;
        rb.constraints.Rotation.z.enabled = true;
    }
    else
    {
        rb.constraints.Rotation.x.enabled = false;
        rb.constraints.Rotation.y.enabled = false;
        rb.constraints.Rotation.z.enabled = false;
    }
}

}

Here is the manual page on rigidbody constraints You can set the constrains by assigning the appropriate enumeration:

rb.constraints = RigidbodyConstraints.None; //No constraints

rb.constraints = RigidbodyConstraints.FreezeRotationX; //Free x rotation

It also looks like its a bitmask, so you can set combine individual constraints by taking the bitwise OR of the enumerations you want

rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationY;

//Freezes x position and y rotation

Commonly used standard usage:

// check if the bool value is true
if (ExampleBool)

// check if the bool value is false
if (!ExampleBool)

Explicit check. Considered a bad practice in general, because it adds in an unnecessary code and usually leads to bad readability. Moreover, in some languages and circumstances the result might be complete opposite. Also, it’s very vulnerable to typos.

// check if the bool is equal to true
if (ExampleBool == true)

// check if the bool is equal to false
if (ExampleBool == false)

// check if the bool is not equal to true
if (ExampleBool != true)

// check if the bool is not equal to false
if (!ExampleBool != false)

Completely wrong usage:

if (ExampleBool = true)

Usually it is a result of the typos mentioned earlier. When you type =instead of == you tell the computer to process the expression inside the parentheses and check if the result is true, the computer performs the operation: set ExampleBool to true ( ExampleBool = true) and check if the result of the operation is true: yeah, the operation was success therefore it’s true, and it doesn’t matter what value the ExampleBool has actually.

PS advice: read some books or at least some basic programming tutorials to learn these very basic and fundamental things like the difference between the assignment operator = and the equation check operator ==.