What's wrong with this JavaScript door script?

Hey guys, i made this script so that i wouldnt have to recreate scripts to open doors everytime. just drag in the animations and sounds. anyway its not working but im not getting any errors either… what could be the issue?

var dooranimationopen : AnimationClip;
var dooranimatioclose : AnimationClip;
var dooropensound : AudioClip;
var doorclosesound : AudioClip;
function OnTriggerEnter(c: Collider)
 {
    if (c.tag == 'Player')  {
        animation.play(dooranimationopen);
        audio.PlayOneShot(dooropensound);
    }
}
function OnTriggerExit(c: Collider)
 {
    if (c.tag == 'Player')  {
        animation.play(dooranimatioclose);
        audio.PlayOneShot(doorclosesound);
    }
}

Should be animation.Play not animation.play.

See below

INCORRECT:

animation.play(dooranimationopen);

CORRECT:

animation.Play(dooranimationopen.name);

Hello,

Now that we have narrowed down the problem, finding the solution is easy XD

Looking at the documentation, AnimationClip does not have a “name” variable (even through it does) meaning that this is undocumented and should not be used.
My suggestion is to iterate through all the animation states to find the matching clip (If you really want to add the clip to the script and not just the name)

//Please use CamelCase, like everyone else :)
var doorOpen:AnimationClip;
var doorClose:AnimationClip;

private var openState:String;
private var closeState:String;

//This iterates through all animations
//attached to the animation component
//If the clip of one of the states matches the clip of
//one of the variables, we reference the name
function Start() {
    for (var state:AnimationState in animation) {
        if (state.clip == doorOpen) {
            openState = state.name;
        }
        else if (state.clip == doorClose) {
            closeState = state.name;
        }
    }
}

//Here we use the name we gathered in Start
//To run the appropreate animations
function OnTriggerEnter(c: Collider) {
    if (c.tag == 'Player') {
        animation.Play(openState);
    }
}
function OnTriggerExit(c: Collider) {
    if (c.tag == 'Player') {
        animation.Play(closeState);
    }
}

Easy as goo pie,
Benproductions1