Set the current rotation of an object to a variable

I would like to get an objects current y rotation and set it to a variable, then use that variable in another script to ensure my 2 objects are always facing the same direction.

Put this script on the object you want to have follow the other object

var otherObject : Transform; // set this in the Inspector

function Update()
{
  transform.rotation = otherObject.rotation;
}