How to make object turn around and go back to original place?

Alright guys, so I have made it so that my model goes from point A to point B and back, but I was wondering if it was possible to make it turn around instead of going in reverse back to its original spot? I know I should add some quaternion thing in there but not sure where or what…

Here’s what I have so far:

var pointB : Vector3;
var speed = 20.0;
var rotateSpeed = 3.0;

function Start () {
    var pointA = transform.position;
   while (true) {
        yield MoveObject(transform, pointA, pointB, 20.0);
        yield MoveObject(transform, pointB, pointA, 20.0);
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
    var i = 0.0;
    var rate = 100.0/time;
    while (i < 1.0) {
       i += Time.deltaTime * rate;
        thisTransform.position = Vector3.Lerp(startPos, endPos, i);


Between moving the object one direction and the second direction, just Slerp the rotation from(0,0,0) to (0,180,0) or whatever it needs to turn around. You can write another function (ie Rotate Object) that just turns it by 180 degrees over some period of time