Destroy 2D obj issue

I have a simple script to keep track of the players health and destruction, but it won’t work fully. The health does work and colliding with objects works fine, but I can’t get it to destroy the object when the player is at 0 health.

using UnityEngine;
using System.Collections;

public class damagePlayer : MonoBehaviour {


	public int playerHealth=30;
	int damage=10;

	void Start()
	{
		print (playerHealth);
	}

	void OnCollisionEnter2D(Collision2D collision)
	{
		if (collision.gameObject.tag == "Colliders")
		{
			playerHealth-=damage;
			print ("Player hit" + playerHealth);
		}
}

	void update()
	{
		if (playerHealth <= 0) 
		{
			Destroy (this.gameObject);
		}
	}


}

Most programming languages are case sensitive, so for example update and Update are not the same thing. You need to fix the name of your Update method so Unity will actually recognize and call it.

Should be just

Destroy(gameObject);

Write “Update()” with capital “U”, not “update()”.