Script error: respawn upon collission

Hello!

I am trying to write a script where the player (in this case just a sphere) respawns (as in, goes back to it’s original position) when it falls off-world. I wrote the following script:

#pragma strict
var position : Vector3;
function OnCollisionEnter(collision:Collision) 
{ if( collision.gameObject.tag == "Finish" ); 
{transform.position : Vector3(0, 0, 0)}; 
}

When trying to execute it, I get the following error:
Assets/Die.js(5,1): BCE0034: Expressions in statements must only be executed for their side-effects.

What is going wrong?

Try with:

#pragma strict
var position : Vector3;
function OnCollisionEnter(collision:Collision) 
{ 
   if( collision.gameObject.tag == "Finish" ) 
      transform.position = Vector3(0, 0, 0); 
}

You have substituted an “=” with a “:”, and this won’t change the position. Also, you’ve ended the if statement with a “;”. It should work now.

Thank you! I ended up using

#pragma strict
var position : Vector3;
function OnCollisionEnter(collision:Collision) 
{ if( collision.gameObject.tag == "Finish" )
 {
 transform.position = Vector3(1,5,-2.8);
 rigidbody.velocity = Vector3(0,0,0);
 } 
}

Which works great as a very basic respawn system. The biggest problem was indeed ending the if-statement with a semicolumn. This caused the script to not actually execute what was defined in the function.