Why doesnt my checkpoint system work?

Hi, im currently trying to get a checkpoint system to work in my game, I have a Kill Volume(as shown in picture 1) that when you touch it, it spawns you back at the beginning, as shown in picture 2!

Which spawns you back here!!!

And when you hit a checkpoint, shown as the other square in picture two, the kill volume should spawn you at the checkpoint(square2) rather than the original spawn point(square 1).



This is my killVolume code, which sends you to the original starting zone

var dest: Transform; // drag the destination object here


function OnTriggerEnter(other: Collider){
  	if (other.tag == "Player"){
    // move the player and align it to the dest object:
    other.transform.position = dest.position;
    other.transform.rotation = dest.rotation;


I have this so far as code to spawn me at square two

static var dest: Transform;

function OnTriggerEnter(item : Collider)
{

if(item.tag == “Player”)

{

“RestartScript”.dest.Transform = “Checkpoint1”.Transform;
}
}



It obviously not working, which is where you all come in. Any ideas on what I could change for the checkpoint script? I have it to where it will respawn the player at the original spot(square1) when I die, but when I hit the checkpoint and die, it doesnt spawn me at the checkpoint(square2).

On your “Kill Volume” add a variable called something like “RespawnPosition” of type Transform like so.

var RespawnPosition:Transform;

Also add a tag to your kill volume called “deathzone” or something similar.

In your checkpoint script write this for the OnTriggerEnter function.

function OnTriggerEnter(other:Collider){
	var killzone : GameObject;
	killzone = GameObject.FindGameObjectWithTag("deathzone");
	killzone.GetComponent(killVolume).RespawnPosition = transform;
}

Now when respawning the player (on your kill volume) do.

function OnTriggerEnter(other: Collider){
    if (other.tag == "Player"){
	    // move the player and align it to the dest object:
	    other.transform.position = RespawnPosition.position;
	    other.transform.rotation = RespawnPosition.rotation;
    }
}

This will make sure that your kill volume knows at which point to respawn the player and it will also make sure that the kill volume actually spawns the player at that point.