Change Location when Colliding

my code doesnt seem to work. i want to change position when i hit an object.

var spawn:Transform;

function OnControllerColliderHit(hit : ControllerColliderHit) {

if (hit.gameObject.tag =="w")

{

transform.position = spawn.position;

}

}

my problem is it does not change it position. as if nothing happened.

try this "hit.gameObject.transform.position = spawn.transform.position;" instead of "transform.position = spawn.position;"

the object location was changed not me.