Temporary Parenting through Scripting

I have a script thats suppose to temporarily parent my object (player) to the animating elevator so it wont fall through the elevator as it goes up. then when its finished i want it to unparent it. however when i test it, it says that the variable "player" hasnt been assigned, even though i drag and dropped it into the player variable. heres my script:

var elevator : AnimationClip;  //animation
var player : GameObject; //object being parented to HoistCar

function OnTriggerEnter (myTrigger : Collider) {

if(myTrigger.gameObject.name == "player") {
        Debug.Log("elevator trigger activated"); //testing to see if trigger works
        HoistCar = GameObject.Find("HoistCar");  //finding gameobject player
        HoistCar.animation.Play("elevator");   //if trigger is activated, play //animation
        player.transform.parent = transform; //parent player to hoistcar if trigger is activated

        }
        else {
        transform.parent = null; //unparent object if animation isnt playing
        }
}

Did you drag and drop a Prefab of the player into your script variable in the designer? If so, you still need to call Instantiate to create an instance of your player or it won't exist yet at runtime.

A prefab is not an instance.

Hey man,

Consider using the "collision" info from trigger enter.

EG (not tested)

 function OnTriggerEnter (other : Collider) {
    other.transform.parent = transform; // You may need other.gameObject.transform.parent = transform;
}

You'll obviously need to drop that parenting onTriggerExit() or similar.