Falling off respawn script

Greetings, I am currently creating a game where you have to jump from one cube to another and not fall off. I was walt textondering if there was any way that I could make it so the player respawns at the original spawn point after falling a little distance. Does anyone have scripts for my request? I am having a very hard time with this as I am quite new to Unity. May you explain in detail exactly what I do to have the player respawn on the original spawn point after falling off? I already created a invisible large rectangle under the map so the player falls off and lands on it. Now what do I do after this? How do I make it so the player teleport to the spawn point after hitting the invisible platform? I have set up something so that if the player falls off, it restarts the scene, but I don’t like it. I want it so that my other scripts (Such as a timer or lives) do not restart when the player falls off.

You need to keep track of the last block your person is on. Then, when he hits the invisible plane, you change his position to where he was at that time.

Do something like…

(on player GameObject)

public Vector3 lastGoodPosition;

void OnCollisionEnter(Collision collision)
{
   if (collision.tag == "Block")
   {
      lastGoodPosition = transform.position;
   }
   else if (collision.tag = "PlaneOfDeath")
   {
   transform.position = lastGoodPosition;
   }
}

You may need to tidy this up a little bit. For example, if the player hits a block as they’re falling they’ll end up in a cycle of death. However, this should get you started on the right path.