Why is my animation not playing?

ANIMATION.PLAY(“ANIMATION”); WHY DOES THIS NOT WORK?
It work it unity 4 but not 5.0.1 I don’t know why. it’s in update function (c#) I looked up it on YouTube but all vids there are for unity 4.
What I really mean is that when I type in “animation” then a “.” It has a list of stuff u can put in after but Play is not there.

Animation anim;

void Start(){
anim = GetComponent<Animation>();
PlayAnimation("AnimationNameHere");
}

void PlayAnimation(string animName){
anim.Play(animName);
}

That should work. You can’t just do Animation.Play, as you have to reference it first. This is independent of any version of Unity as far as I know.

Get a ref for your object with the animation you want to play

    public GameObject refObj;

Then play using the obj and the animation name

refObj.animation.Play("AnimationNameAsString");

In Unity 5, they removed many of the direct-access variables such as animation. Instead of using the animation variable which accesses the Animation component on the GameObject, you have to either initialize it yourself in the Awake or use GetComponent().Play instead.