Object Reference not set to an instance of an Object

I am working on A HUD for my FPS game and i am having some trouble with the Health Script. to be more specific the problem is with the new 4.6 UI i have tried all day to fix this. Some Please Help.

EDIT: I somehow think that this code may be important (sarcasm)

using UnityEngine.UI;
public class BASEH : MonoBehaviour {

	public string input = "Please Enter Text";
	public GameObject otherGameObject;
	
	
	private health anotherScript;



	Text text;
	
	void awake(){
	//	Health = this.GetComponent(Health);
		anotherScript = otherGameObject.GetComponent<health>();
		text = GetComponent<Text>();
		Debug.Log("Another"+" "+anotherScript.GetHealth());
	}
	// Use this for initialization
	//void Start () {
	//	Debug.Log("Another" + " " + anotherScript.GetHealth());
	//}
	
	// Update is called once per frame
	void Update () {
		//text = GetComponent<Text>();	
		text.text = input;//anotherScript.GetStringHealth();//input;
	
	}

}

are you calling your awake() function? Unity will NOT call it … it needs to be Awake()

you may have other problems, but that’s likely to contribute to your problems.

why do you think “EDIT: I somehow think that this code may be important”?

EDIT: it’s good practice to use CamelCase when naming functions & classes… health should be Health. also, be careful to not use the same names as Unity… text is one of them… it’s not an immediate problem here, but it could be later on.

Check these:

  • Make sure this game object has component Text
  • otherGameObject is assigned in Inspector
  • otherGameObject has component “health”