How do I use x rotation in script?

PLEASE READ THIS! I am terrible at coding and need some help on how to do this. I have this script here:

if (transform.rotation.x > 20)
{
doSomething();
}

I don’t know why this isn’t working. I am really bad at coding so keep your answers very simple please. I just need a solution to this problem or another way of doing what I want it to do.,PLEASE READ THIS! I am terrible at coding and need some help on how to do this. I have this script here:

public Rigidbody rb;

if (transform.rotation.x > 20)
{
doSomething();
}

I don’t know why this isn’t working. I am really bad at coding so keep your answers very simple please. I just need a solution to this problem or another way of doing what I want it to do.

transform.rotation is a Quaternion, whereas the X Y Z values shown in the inspector are showing the objects local Euler angles, which can be accessed in code with transform.localEulerAngles.

Try this:

if (transform.localEulerAngles.x > 20) { doSomething(); }