2D Animation Help, noob question

Ok I Started today to learn 2D animations and what I did was importing a sprite that I later sliced to make the frames of an explosion, I created and adjusted a 2D animation out of it and if I put the object in the scene as soon as the game start said animation loops continuosly and everybody is happy and lives free.
But as soon as I set the gameobject animation not to loop after it has finished, and try to code that after it finishes said gameobject needs to be destroyed (no need to have the final frame of an explosion on the screen) I get an exception : “There is no ‘Animation’ attached to the “DefExplosion” game object, but a script is trying to access it.”

Here’s what I’ve tried so far :

    public class ExplosionEnd : MonoBehaviour {
     
        Animation Anim;
     
        // Use this for initialization
        void Start ()
        {
            Anim = GetComponent<Animation>();
            gameObject.GetComponent<Animator>();
            gameObject.GetComponent<Animation>();
        }
       
        // Update is called once per frame
        void Update ()
        {
            if (!gameObject.animation.isPlaying)
            { Destroy(gameObject); Debug.Log("Destroyed"); }
        }

the above script is attached to the gameobject that has the animation and need to be destroyed afterwards… what am I missing here ?

Hi Dude LIKE MY answers!

1 - Create this CODE in C# and drag in your object:

    using UnityEngine;

    using System.Collections;

    public class DestroyAnimatio : MonoBehaviour {

    void DestroyAfeteranimation() {   
    Destroy(gameObject);
   }

 }

2 - Open in : Window > Animation

3 - Create your animation and determine the time.

4 - Still in the Animation window, click the mouse exactly in the range of destruction of the object. With setada position on the chart, add an event by clicking ADD EVENT ', near ADD FRAME.

5 - Will open a small screen called “Edit Event Animation”. Select the function created in the above code.

6 - READY! Start the game NOW!

Hope that helps you!

TIP A FRIEND FOR SELECT LOOP ANIMATION >

(http://files.photosnack.net/albums/images/d3d4f1d5abe364aa2ccacdi212747256/scale-1000x1000)

Did you create the animation clip by selecting the character game object and then create it ? I did not and it created problems for me just yesterday.