I have a simple test script to display a message, but I'm getting an error of NullReferenceException on runtime. Here's my code:
Text messageText;
void Start ()
{
messageText.GetComponent<Text>();
}
void Update ()
{
messageText.text = "Test";
}
But when I try to put my more complex script, it run and changes the value of my messagebox, here's my other script:
Text expText;
public Fighter fighter;
void Start()
{
expText = GetComponent<Text>();
}
void Update()
{
expText.text = fighter.levelingSystem.currentExp + " / " + fighter.levelingSystem.maxExp;
}
Here's my error:
NullReferenceException: Object reference not set to an instance of an object MessageText.Start () (at Assets/MessageText.cs:11)