Rotation promlems past 90 and 270

Problem with rotation and I can’t seem to fix it. Here is what I am using:

function Update()
{
transform.rotation.x += 20* Time.deltaTime;
}

or

function Update()
{
transform.RotateAround (transform.position, Vector3.right, 20 * Time.deltaTime);
}

What happens with the first one is it gets to a point and stops moving. The numbers on rotation x seem to stick around 0-1 without actually stopping. The rotate around script animated the object correctly, but the rotation of x goes up from 270 to 90, then counts back down to 270 after flipping the Y and Z rotation from 0 to 180.
If I rotate manually in play mode and switch to the scene view to rotate using tools, it does the same thing.
If I am trying to use something to match the rotation, it’s fine for half the rotation on the x axis, but once it gets past the 90 and starts counting back down it messes it all up.
any idea why it does this?

Transform.rotation is a 4D quaternion, and rotation.x does not correspond to the x axis. Use Transform.Rotate instead. There is more than one valid way to represent a quaternion as euler angles (e.g. 0,0,0 is identical to 180,180,180), so reading one axis by itself is somewhat meaningless.

Tried to put it in an empty object an then rotate in local space:

transform.Rotate(Vector3.right * Time.deltaTime *20, Space.Self);

That should do it.

Hello ,
try to fixe your zone of work , 0 to 90 0 to 180 or 0 to 360

and se ur variable like this

alpha =((transform.eulerAngles.x%360)%180)%90;

So here the % have a role to find the angle betwen 0 and 90 180 360 …

2kpi in math