Help with turning this into only x

I need someone to turn this code into so it only moves on the x-axis and not the y-axis.
{
public float speed = 10f;
private Vector3 targetPosition;
private bool isMoving;
public GameObject clickAnimation;
// Use this for initialization
void Start()
{

    }

    // Update is called once per frame
    void Update()
    {
            targetPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            targetPosition.z = transform.position.z;
            if (isMoving == false)
            {
                isMoving = true;
                Instantiate(clickAnimation, targetPosition, Quaternion.identity);
        }
        if (isMoving == true)
        {

            transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
        }
        if (targetPosition == transform.position)
        {
            isMoving = false;
            Destroy(GameObject.Find("Click Animation(Clone)"));
        }
    }
}

@boss2070301, you can’t directly set the transform.position.x, so you have to store your move position in a Vector3 first. then you want to use the x position from that result together with the current y and z position of your transform.

There are lots of ways you can cut this and end up with the same pie, so here is one way in pseudo code

 Vector3 newPos = your move pos function call
 newPos = new Vector3( newPos.x, transform.pos.y, transform.pos.z )
 transform.pos = newPos

That will keep the same y and z but x will change

Also this line of code will probably never be true no matter how you move your objects, so better to check the distance between your target and your transform against some threshold, again in pesudo code:

  // won't be ever true unless you explicitly set their x, y, and z
  //      exactly the same non decimal floats
  if (targetPosition == transform.position)

  // do this instead
  if(  Vector3.Distance( targetPos , trans.pos ) <= 0.001f  )
  // will be true if they are within 1mm of each other
  //  change the threshold to the value you like