Rotate on one axis

I was wondering how I can restrict the following code to rotate around the z axis only?

Quaternion targetRotation = Quaternion.LookRotation(target.position - turret.transform.position, Vector3.up);
turret.transform.rotation = Quaternion.Slerp(turret.transform.rotation, targetRotation, Time.deltaTime * 2.0f);

I'm working on a top down game so I only want it to rotate around one axis to face the player. Can it be done the way im trying above?

Thanks

You could try setting the look direction z to zero. I created a temporary variable to illustrate this easier.

var lookDirection = target.position - turret.transform.position;
lookDirection.z = 0;

var targetRotation = Quaternion.LookRotation(lookDirection, Vector3.up);
turret.transform.rotation = Quaternion.Slerp(turret.transform.rotation, 
                                        targetRotation, Time.deltaTime * 2.0f);

I haven't tested this but it should be easy enough to test this for you with 2 more lines of code.

Quaternion rotation = Quaternion.LookRotation(rotation, Vector3.up);

This line in the code shows some semicolon error. I do not understand what error it is. Error says, there should be a semicolon in the end.