NullReferenceException: Object reference not set to an instance of an object
I am getting the following error in my script and i dont know why here is the script
NullReferenceException: Object reference not set to an instance of an object Coin.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Coin.js:11)
#pragma strict
public var Money : MenuShopSystem ;
function Start () {
}
function OnTriggerEnter2D (other: Collider2D)
{
Debug.Log ("Touch");
Money.Money += 100;
Destroy(this.gameObject);
}
Answer by pekalicious · Dec 03, 2015 at 03:33 AM
Sounds like the Money field in the inspector isn't linked to anything, or generally no script is setting the Money variable to anything.
Select your game object that contains this script, find the Money field in the inspector and drag and drop your game object that contains the MenuShopSystem script.
Your answer
Follow this Question
Related Questions
Error BCE0051 with script JS 1 Answer
Help with JS script 0 Answers
Inventory System: NullReferenceException Error 1 Answer
Why am I getting a null reference error? 1 Answer
NullReferenceException after save the Scene and Project 0 Answers