compass bar on space ship, weird rotation

so i have a 3d ring that is a child of my spaceship. i only want the ring to appear to move side to side like a compass when my space ship is moving.

so the y is always quaternion.identity.
but the x and y have to be the same as the space ship, so it doesnt look like the ring is moving all over the place?
ive tried all kinds of things. either its totally wonky. or it kind of stutters. and follows the player but doesnt point to y identity.

any ideas.

alright i figured it out. player is target.

#pragma strict

var target : Transform;


function Start () {
	
}

function Update () {
	 var euler = target.transform.rotation.eulerAngles;

 var rot = Quaternion.Euler (0,-(euler.y),0);
 transform.localRotation = rot;
}