Variable containing a transform is modifying the object's transform it is referenced to.

I am trying to have a smooth movement portion to my app where I click a button and the camera will move to the next waypoint. Here is the relevant code snippets:

 Transform target;

  cam = GameObject.Find("ThirdPersonController");
        target = cam.transform;

if (shouldMove == true)
        {
            // Debug.Log(target.position);
            cam.transform.position = Vector3.MoveTowards(cam.transform.position, target.position,  Time.deltaTime*speed );
        //    cam.transform.rotation = Quaternion.RotateTowards(cam.transform.rotation, target.rotation, Time.deltaTime * speed);
        }

  public void clickedForward()
    {
        Debug.Log(target.name);
        target.position = currentWayPoint.forward.getPos();
        target.rotation = currentWayPoint.forward.getRot();
        shouldMove = true;
        currentWayPoint = currentWayPoint.forward;
           

    }

When I click the forward button it jumps the camera straight to the forward waypoint, completely ignoring the MoveTowards() method? I think it is because target = cam.transform; is being referenced in the wrong way. Any tips?

I fixed it by assigning my start waypoint’s transform to the target as opposed to the camera’s transform value.