Imported animations won't play

I made a character in 3dsmax and animated it, then imported it into unity as an fbx file.
I want to control the animations using this script:

var villager_Walk : AnimationClip;
var villager_Idle : AnimationClip;

var animState : int = 0;

function Update () {
		if (animState == 0){
			animation.Play("villager_Idle");
		}	
	
		if (animState == 1){
			animation.Play("villager_Walk");

however, I keep getting this error message:
“the animation state could not be played because it could not be found”
and it only plays the default animation.

normally this is fixed by setting the animations to legacy, but I’ve already done that and it still logs this error.
I can get each of the animations to work in the preview, and i can use any of them as the default animation.
what am I doing wrong?
here is the object’s inspector settings:

You should have a gameobject variable in which your animations are.
Example

var target : GameObject;

function Update () 
{
         if (animState == 0){
             target.GetComponent.<Animation().Play("villager_Idle");
         }    
     
         if (animState == 1){
             target.GetComponent.<Animation().Play("villager_Walk");
}

That should work.