Making a Cube Destroy When Touching Another Cube

I’m using a script that acts as a gravity gun that lets my move around cubes with a rigidbody, I want to make an if statement script with two vars Cube1 and Cube2 that says if cube 1 touches cube 2 destroy cube 1 but I’m still a little new to making scripts in unity and am not sure how to go about doing this.

You may add a new tag (name it “Cube”), attach it to your cubes, and then add the following script to the cubes:

using UnityEngine;
using System.Collections;

public class CubeScript : MonoBehaviour {
    void OnCollisionEnter (Collision col) {
        if(col.gameObject.tag == "Cube")// "Cube" or whatever you named the new tag

This script destroys the containing game object when it collides with another game object with tag “Cube”.

Thank you this works great. Should have said I prefer Javascript put C# is fine.