Object isn't respawning the character please help!

Hi so I am trying to make in my game that when my player touches a tree it respawns you back to the start, lets just put it out their I am a newbie at this so I am probably doing many things wrong. If someone could explain this concept to me and help me out with my code that would be great thanks :D.Here is my code that I have:

var player:GameObject;
function OnCollisionEnter(theCollision : Collision)
if(theCollision.gameObject.name === “player”)
transform.position.y = 108;
transform.position.x = 20; // this is the place where my character spawns
transform.position.z = 20;

again thanks anyone who helps me out :smiley:

The transform.position vector is a struct, you cannot set its values individually (x, y,z). You have to replace the entire vector. Something like:

 transform.position = new Vector3(20, 108, 20);

Look here.