Why isn't my object destroying on collision?

Hello! I’m rather new to game development and I’m having trouble making an object disappear when the player touches it.

You can see the code for the script here:

using UnityEngine;
using System.Collections;

public class collect : MonoBehaviour {

	void Update ()
	{
		
	}

	void OnCollisionEnter(Collision col)
	{
		if(col.gameObject.name == "platform")
		{
			Destroy(gameObject);
			Debug.Log("collision detected!");
		}
	}
}

The object being destroyed is called “platform” because it was originally being used as a platform in-game. You can view its inspector here:

Why won’t this code work?

Thanks in advance!

In your platform’s script, you’re checking if the platform is colliding with itself. You should change it to check if the platform is colliding with the player instead.

     void OnCollisionEnter(Collision col)
     {
         if(col.gameObject.name == "Player")
         {
             Destroy(gameObject);
             Debug.Log("collision detected!");
         }
     }