GUI Text doesn't change, provided error unknown

using UnityEngine;
using System.Collections;

public class ignition : MonoBehaviour {

    public GUIText hpDisplay;
    public double health = 100.00;
    // Use this for initialization
    void Start() {
        string hpDisplayReady = "HP: " + health;
        hpDisplay.text = hpDisplayReady;
    }

    // Update is called once per frame
    void Update() { }
    void OnTriggerEnter(Collider firebox) {
        if (firebox.gameObject.name == "Player") {
        }
    }
    void OnTriggerExit(Collider firebox) {
        if (firebox.gameObject.name == "Player") {
            Debug.Log("HP decrease turndown.");
        }
    }
}

This is my code, it isn’t worked out yet, but I need to work out the bugs before attempting to add new things. I wanted to display “HP: 100.00” or “HP: 100” on GUI text. When I run “the game”, “Gui text” doesn’t change to either of provided expected answers… the error I get, on the bar beneath and in-console too is:

“UnassignedReferenceException: The variable hpDisplay of ignition has not been assigned.
You probably need to assign the hpDisplay variable of the ignition script in the inspector.
ignition.Start () (at Assets/ignition.cs:11)”

Most probably you do not assign the GUIText to your script.

If you assigned the script to an object you must see to fields in the inspector (similar to the screenshot). Drag and Drop the GUIText object into the “slot” hpDisplay.

1 Like

Yep, I forgot to drop the box in the thingie, thank you Sir.