Error with Lerping

Hi I am trying to implement a simple lerping to make an object to move from one to point to the next continuously, however I seem to get the following error: ‘cannot convert from unityengine.transform to unityengine.vector2’ with the code below:

 public Transform StartPositionGo;
    public Transform EndPositionGo;
    float StartTime;
    float TotalDistancetoDestination;


    void Start()
    {
        StartTime = Time.time;
        TotalDistancetoDestination = Vector2.Distance(StartPositionGo.position, EndPositionGo.position);
    }

    void Update()
    {
        float currentDuration = Time.time - StartTime;
        float journeyFration = currentDuration / TotalDistancetoDestination;
        transform.position = Vector2.Lerp(StartPositionGo.position, EndPositionGo, journeyFration);
    }

}

So what would be a way to resolve this, thank you.

That error means that somewhere in your code (and the error message will tell you the line number where the error is), you’re using a Transform where you should be using a Vector2, and I can see where it is.

Change

 transform.position = Vector2.Lerp(StartPositionGo.position, EndPositionGo, journeyFration);

to

 transform.position = Vector2.Lerp(StartPositionGo.position, EndPositionGo.position, journeyFration);

Hi thanks, I tried implementing that but for some reason the object just moves from the start position to the end position and stops. I made sure that the for the Z axis and the position for the Z axis is set to 0 but it seems like it just gets stuck. Any suggestions? I desired it to move back and fourth continuously.