How would I fix my script to make a checkpoint?

So I have made a good respawn if the player falls off of a block. But I can’t figure out how to make the checkpoint. I realize my problem with the script is that the player is now constantly teleporting to the new area, but I don’t know how to fix it. Here is my script so far, hopefully, you can help!

var MaxFallDistance : float = -5;
var Distance = 142;

function Update ()
{
if(transform.position.y <= MaxFallDistance)
transform.position = Vector3(-1.2, 32.2, -2.37);

if(transform.position.x >= Distance)
transform.position = Vector3 (142, 27.5, -0.8905);
}

Instead of hard-coding it in there, use a Vector3 variable called lastCheckpoint. Make lastCheckpoint equal your spawn position at start. If the player passes through another checkpoint (I would use an invisible, trigger collider), set lastCheckpoint to that checkPoint position. That’s how I would do it, anyways.

I feel bad for asking this, as I try to figure things out on my own. However, I am very confused on what you think I should take out and put in. Should I be putting the lastCheckpoint after the variables for my digits on Vector3? Or should I be replacing the Vector3 entirely? I’m sorry in advance.

Thanks!