GameObject MoveTowards Another GameObject

So when i click the object with the tag building it will move towards it, but it doesn’t it just jitters?
It doesn’t move Y As well.

Code:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Attack : MonoBehaviour {

    public float speed;
    public Scrollbar Health;
    private Vector3 target;

    void Start()
    {
        target = transform.position;
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            target.z = transform.position.z;

            RaycastHit hitInfo = new RaycastHit();
            bool hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo);
            if (hit)
            {
                Debug.Log("Hit " + hitInfo.transform.gameObject.name);
                if (hitInfo.transform.gameObject.tag == "Building")
                {
                    transform.position = Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime);
                }
                }
            }
            }
        }

I don’t think you should change the target.z, rather you should give the mouse position a z.

Vector3 mPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mPos.z = Vector3.Distance(Camera.main.transform.position, transform.position);

or something like distance because if the camera is not at the origin, transform.position.z probably wont work.