Hi,
Here is the console picture with error:
Here is the code:
using UnityEngine;
using System.Collections;
public class Money : MonoBehaviour
{
int Dinero;
public void DineroFunc(int value)
{
return Dinero = Dinero + value;
}
public void OnGUI ()
{
GUI.Label (new Rect (10, 10, 100, 20), "Money: "+ Dinero);
}
}
The other one:
using UnityEngine;
using System.Collections;
public class add : MonoBehaviour
{
Money Dinero;
int numero = Random.Range(10,500);
// Update is called once per frame
void Update ()
{
GameObject.FindGameObjectWithTag("Player").GetComponent(Money);
}
void OnMouseUp()
{
if(gameObject.tag == "Oro")
{
Dinero.DineroFunc(numero);
Destroy(gameObject);
}
}
}