(moved from comment)
probably this line (the error says it’s on line 4 of the script ClickBuyLaser):
if(ScoreSystem.myscore >= 500000){
if myScore is a static var, this should work with the script named ScoreSystem… (as written)
otherwise you need an instance of the script you’re trying to access.
var scoreScript : ScoreSystem;
function Start(){
scoreScript = GameObject.Find("Player").GetComponent(ScoreSystem);
}
function OnMouseDown(){
if(scoreScript.myscore >= 500000){
etc
if you make it static, there’s only one instance of the var across all scripts, which is why you could access it that way, without an instance…
otherwise, you have to point to the specific instance of the script you wish to access, hope that’s clear…
So if, for example, I have a script which is used more than once, say an enemy script called EnemyScript on all my enemies, and in it I declare a var:
static var myDamage : int;
if I set myDamage to 10 on one of my enemies, it changes on ALL of them (to 10)…
because it is static there is only one instance of the var, across all instances of the script.
Because of this, I can access it directly with : EnemyScript.myDamage = 10;
But if it’s not static, I need to specify the instance of the script to access the var on, otherwise there’s no way to know which enemy I mean…
In your case, using static may be the way to go, if you know the var myscore should always refer to the same instance…
Otherwise just create a var to reference the script as above
EDIT: change myscore to myScore
if(ScoreSystem.myScore >= 500000){
EDIT: here’s the whole thing
var Laser : Transform;
var showGUI = false;
function OnMouseDown(){
if(ScoreSystem.myScore >= 500000){
ScoreSystem.myScore -= 500000;
Instantiate(Laser,transform.position,Quaternion.identity);
Destroy(gameObject,0.0);
}
else
showGUI = true;
}
function OnGUI(){
if(showGUI){
GUI.Label(Rect((Screen.width / 2.1) + 20,10, 200, 30), "Can't Buy");
}
}
function Update(){
if(Input.GetButtonUp("return") && showGUI) //or whatever...
showGUI = false;
}