2D Moving Platform script issue?

I found a tutorial for moving platforms as well as sticking to them and I wrote the script exactly as they did, but my platform is going to a spot that was never called from my Position 1/2 variables.

using UnityEngine;
using System.Collections;

public class MovingPlatform : MonoBehaviour {

    public Transform movingPlatform;
    public Transform position1;
    public Transform position2;
    public Vector3 newPosition;
    public string currentState;
    public float smooth;
    public float resetTime;

    void FixedUpdate(){
        movingPlatform.position = Vector3.Lerp (movingPlatform.position, newPosition, smooth * Time.deltaTime);
    }

    void ChangeTarget(){
        if (currentState == "Moving To Position 1") {
            currentState = "Moving To Position 2";
            newPosition = position2.position;
        }
        else if (currentState == "Moving To Position 2") {
            currentState = "Moving To Position 1";
            newPosition = position1.position;
        }
        else if (currentState == "") {
            currentState = "Moving To Position 2";
            newPosition = position2.position;
        }
        Invoke ("ChangeTarget", resetTime);
    }
}

Instead of it going between my Position 1 and Position 2 transforms, the platform just moves as if I sent it somewhere unspecified.

I used this video. I used a 3D example for something else and just changed around some 2D code, but I am not sure what I am missing with this.

Let me know if you need more information. This is my first time posting about anything like this. Thank you

is currentState being set to proper values ? You can Debug.Log at each state change
and see if atleast the state changes are happening properly.

It looks as if currentState is not initialized to “” and that check is failing and hence newPosition
never got set properly in ChangeState

I tried adding Debug.log but I guess I am doing it wrong, I keep just getting errors on the debug line.

Also, if it helps, the platform never returns and “currentState” or “newPosition” never change their values. The platform just moves somewhere undefined and stops.

This is happening because your platform is not initialized to proper states.
Can you show how you are adding the Debug.Log lines ?
(Its actually Debug.Log and not Debug.log)

I fixed it, thank you. I just used another method.