Destroy Object On Touch? 2D

Hello, I am making a game where part of it you have to tap the right square “Object” to proceed. I thought it would be simple to just code it but then again I am considered a noob when it comes to scripting. All help is appreciated.

Some info on what I want- The game is 2D, I want the object to be destroyed instantly when tapped on.

  1. Make sure you have a collider on your square object, e.g. BoxCillider2D

  2. Attach the following script on the square object:

    using UnityEngine;

    public class KillSquare : MonoBehaviour {

    void OnMouseDown()
    {
    
        Destroy(this.gameObject);
    
    }
    

    }

It will work as you want.