I know that there are a lot of Answers to this problem already, but I am still very confused on what to do here. When I run my script I get the null reference exception, here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameControl : MonoBehaviour {
public static GameControl control;
public static int health;
public static int XP;
public Text Health;
public Text EXP;
void Awake(){
Health = GetComponent<Text> ();
EXP = GetComponent<Text> ();
if (control == null) {
DontDestroyOnLoad (gameObject);
control = this;
} else if (control != this) {
Destroy(gameObject);
}
}
void Update(){
Health.text = "Health: " + health;
EXP.text = "XP: " + XP;
}
}