Rotation problem

     if(20 < transform.rotation.y < 50)

     {
     }

Why does the above segment of code produce an error?

Don't add 2 inequalities together like that. Instead check for both seperately.

if(transform.rotation.y > 20 && transform.rotation.y < 50) {
     //Do stuff
}

Note that even with the syntax errors fixed, the code is still functionally incorrect. Transform.rotation is a quaternion, and is constrained to be unit-length. As such, the conditional will always return false, which is probably not what you want.

If you want to work with angles directly, use Transform.eulerAngles instead. (Be aware though that due to aliasing, the returned angles may not always be what you expect.)