Why does my game objects Y axis rotate automatically?

Hi, I’m working with A* path finding and am trying to get some enemies to face the player:

void Update(){
	transform.LookAt (target.position);
	transform.Rotate (new Vector3(0, 270, 91),Space.Self);

However when the game runs, if the enemy rotates too far on the Z axis, the Y axis also rotates and due to this the collider on the enemy is removed until it further rotates on the Z, and it’s Y axis is back to original.
So my question is how can I have my enemy face the player via Z axis since it’s a top down shooter game, but also stop the Y axis from automatically rotating itself?

Get rid of the transform.Rotate line, and with lookat you could try:

transform.LookAt(new Vector3(target.transform.position.x, 0, 0,));

Now it only rotates on the X axis. You have to figure out on which axis you want your character to rotate.

Something I didn’t mention, is that my game is 2D which looking around seems to be that others are looking for an lookAt 2D equivalent.

Found the answer in this thread, for anyone else: