When my player character dies from an enemy collision, a heart from the heart system hp system I used stays there with an error message. What can I do?

The error message goes as follows
“The object of type ‘Transform’ has been destroyed but you are still trying to access it, your script should either check if it is null or you should not destroy the object”

With the heart health system I used, the heart should be gone when the player is dead, but it still stays there with the error message stated above. What could I do?

Here is my code:

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

public class HealthPoints : MonoBehaviour
{
    #region Variables
    public int health;
    public int numOfHearts;
    public Image[] hearts;
    public Sprite fullHeart;
    public Sprite emptyHeart;
    public int damage = 1;
    public GameObject hitEffect;
    #endregion
    void Update(){
        if(health > numOfHearts){
           health = numOfHearts;}
        for (int i = 0; i < hearts.Length; i++){
            if(i < health){
                hearts*.sprite = fullHeart;*

}else{
hearts*.sprite = emptyHeart;}*
if(i < numOfHearts){
hearts*.enabled = true;}*
else{
hearts*.enabled = false;}*
} }
void OnTriggerEnter2D(Collider2D hitInfo){
if (hitInfo.gameObject.CompareTag(“Enemy”)){
if (health != null);{
Instantiate(hitEffect, transform.position, Quaternion.identity);
PlayerTakeDamage();}
} }
void PlayerTakeDamage(){
health -= damage;
if(health <= 0){
PlayerDeath();}
}
void PlayerDeath(){
Destroy(gameObject);
}
}

Your code is very bothersome to me, you stick your ending curly brackets on the same line as your last statement, this doesn’t affect your code when it runs, but I would stop doing that, it makes your code less readable. On line 32 this is your code

             if (health != null);{

there is a semicolon after your parentheses, this is probably what the error is.