You cannot acces the gold amound like this
mainScript = GameObject.Find ("Main Camera").GetComponent(goldAmount);
GetComponent is meant for getting components of an object.Like getting the transform property or a script but definetly not a variable from that script.
Try like this:
var MainScript = GameObject.Find ("Main Camera").GetComponent("mainScript");
//i would change the variable named mainScript too so there are no confusions...
//then you acces it through the MainScript object
MainScript.goldAmount = 100;
↧