The animation does not play when I click

I do not know what is the problem. I often tried to find the problem myself and fix it, but all my attempts fail and until I could find the problem. I apologize if this issue was already raised here, I could not find a solution. I read a few of the topics here about this when people came across a similar problem like mine, but none of the answers provided helped me achieve the desired. These are the topics first and second. Maybe I did something wrong.
That’s what I did:
104028-gjnceip.png

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class animate : MonoBehaviour {

	public Animator anim;

	void Start () {
		anim = GetComponent<Animator> ();
	}
	
	void Update () {
	}
}

Then I tried to add this to my level manager:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ManagerLevel : MonoBehaviour {

public animate at;

void Update () 
		if (Input.GetMouseButtonDown (0)) 
		{
			Vector2 pos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
			RaycastHit2D hit = Physics2D.Raycast (pos, Vector2.zero);
			if (hit.collider != null) {
				//Debug.Log (hit.collider.tag == "Bomb");
				if (hit.collider.tag == "Bomb") 
					Destroy (hit.collider.gameObject);
					addPoints ();
					sm.bombBoom.Play ();
					at.anim.SetTrigger ("explos");
				}
                        }
		}
	}
}

But I did not succeed and Unity shows an error:


I need any option where the animation will be played when clicking on objects with the tag “Bomb”. Help me, pls.

I recommend u to go here
animation

check this out I hope it will help u

@JiLleON , try move the line

 Destroy (hit.collider.gameObject);

after

at.anim.SetTrigger ("explos");

Your code is fine but i think the object was destroy immediately and then you try to access it. Should be play the animations first, then destroy it.