Follow Script, Locking Y Axis

So i have an object in the game that i want to have follow the player. It does follow the player BUT its Y Axis is too high. How can i lock the objects Y Axis along with this code:

transform.LookAt(target.transform);
transform.Translate(new Vector3(0,0,walkspeed *Time.deltaTime),Space.Self);

Also, this is in the Update function.

Chances are, the target you’re actually looking at is that high. Try storing the current y-axis before calling transform.LookAt(target.transform);
For example:

float tempY = transform.localEulerAngles.y;
transform.LookAt(target.transform);
transform.Translate(new Vector3(0,0,walkspeed *Time.deltaTime),Space.Self);
Vector3 temp = transform.localEulerAngles;
temp.y = tempY;
transform.localEulerAngles = temp;