Hello so im new to java script, and get this error
No appropriate version of ‘UnityEngine.Component.GetComponent’ for the argument list ‘(function(): void)’ was found.
im trying to get the “money” var from the the Main script to use in my Store script.
Here is my codes:
First one:(called Main)
#pragma strict
var clicks : GameObject;
var totalclicks : GUIText;
var moneytext : GUIText;
var clicked : boolean = false;
var click : int = 0;
public static var money : int = 0;
function Start () {
click = 0;
money = 0;
}
function Update () {
totalclicks.text = "Total Weeds: " + click;
moneytext.text = "Weed Money: " + money;
}
function OnMouseDown()
{
click += 1;
money += 1;
}
------------------------
Second one(called Store):
#pragma strict
var factoryt : GUIText;
var factory : int = 0;
private var mainScript : Main;
function Awake (){
mainScript = GetComponent(Main);
}
function Start () {
factory = 0;
}
function Update () {
factoryt.text = "Factory: " + factory;
}
function OnMouseDown(){
if(mainScript.money >= 100){
factory += 1;
mainScript.money -= 100;
}
}