Cannot convert 'UnityEngine.Vector3' to 'float'

Sup everybody! I’m trying to make a 2d platformer but I’m having trouble making a group of platforms move back and forth continuously. The error I get is “cannot convert ‘UnityEngine.Vector3’ to ‘float’”. I’m new to coding so this is probably a simple fix but I can’t find the answer anywhere!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class platformMove : MonoBehaviour
{
    public Transform posA;
    public Transform posB;

    bool movingForward = true;

    float elapsedTime;
    public float duration = 2f;

    // Update is called once per frame
    public void Update()
    {
        elapsedTime += Time.deltaTime;
        if(movingForward)
        {
            transform.position = Mathf.Lerp(posA.position, posB.position, elapsedTime / duration);
            if (elapsedTime >= duration)
            {
                return;
            }
            elapsedTime = 0f;
            movingForward = false;
        }
        else
        {
            transform.position = Mathf.Lerp(posB.position, posA.position, elapsedTime / duration);
            if(elapsedTime >= duration)
            {
                elapsedTime = 0f;
                movingForward = true;
            }
        }
    }
}

The errors are on line 21 and line 31 (if you checked the console), and it’s because instead of writing: transform.position = Mathf.Lerp(posA.position, posB.position, elapsedTime / duration); you’re supposed to use: Vector3.Lerp which lerps Vector3’s such as position vectors. So the line should be: transform.position = Vector3.Lerp(posA.position, posB.position, elapsedTime / duration);