NullReferenceException: Object reference not set to an instance of an object

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

public class HUD : MonoBehaviour {

public Sprite[ ] HeartSprites;

public Image HeartUI;

private Healthforplayer player;

void Start () {

This one —> player = GameObject.FindGameObjectWithTag(“Player”).GetComponent();

}

void Update () {

and this one -----> HeartUI.sprite = HeartSprites[player.curhealth];

}

}

This means you probably haven’t tagged your player object in scene with a tag “Player”. Make sure that when you click on a player object, in the top-right corner, you see Tag: Player.

Thanks man ive been on this for like 6 Hours and u help me thanks ily no homo

No problem. Glad I could help :slight_smile: