Properly Rotating Child Objects by Script

I have been having a problem with trying to rotate a child object smoothly but it will switch between inheriting the rotation of the parent, and then to actually paying attention to the script on what its rotation should be. The line responsible for this rotation is this:

transform.eulerAngles = new Vector3(xRot, yRot, 0);

Is this the way to do this, or is there a better way? Thanks!

Actually, it is much easier to use transform.localeulerangles. This is the child’s rotation relative to the parent’s.