Question by
ghostspider155 · Mar 17, 2016 at 02:15 AM ·
error message
Please Help (Java Coding)
NullReferenceException: Object reference not set to an instance of an object ammoDisplayerHub.Update () (at Assets/Scripts/ammoDisplayerHub.js:9)
Is the Error!
And
#pragma strict
import UnityEngine.UI;
var ammoCounter : Text;
var ammoCount : int = 0;
function Start ()
{
//ammoCounter = GetComponent.<Text>().ammoCounter;
}
function Update ()
{
ammoCounter.text
}
function setAmmo ()
{
Debug.Log("Yup!");
}
is the coding
Comment
Answer by Restemayer · Mar 17, 2016 at 02:41 AM
Well, you currently have the line to instantiate the object commented out, for one. The object is never instantiated, so it doesn't exist to be referenced.
Well I have the text already set up in the inspector. The problem I am having is you can't assign a number to the Text it self...
With this error would popup NullReferenceException: Object reference not set to an instance of an object ammoDisplayerHub.Update () (at Assets/Scripts/ammoDisplayerHub.js:14)
Your answer
![](https://koobas.hobune.stream/wayback/20220612072130im_/https://answers.unity.com/themes/thub/images/avi.jpg)