create GUI.Label and then access to it..

So need to create GUI.Label and then access to it…

first script :



var style : GUIStyle;

public var SCORE = "0";

function OnGUI () 



    GUI.Label (Rect (Screen.width*0.2, Screen.height*0.15, 100, 20), SCORE,style);




function Start()


    var LOAD : test;

    LOAD = GetComponent(test);



test and test_access - both different object…
error NullReferenceException: Object reference not set to an instance of an object

If you have the scripts on a different object you have to tell it which object to look for.

var myObject = GameObject.Find("ObjectsNameHere");

LOAD = myObject.GetComponent(test);

You need something in test_access.js that refers to the component with test.js on it - then call GetComponent on that - or just assign it in the inspector:


  var theOtherObject : test;
function Start() {

     theOtherObject.SCORE = "1";



var otherObject : GameObject;

function Start() {

    otherObject.GetComponent(test).SCORE = "1";


Please remember naming conventions really help - your scripts (and their inherent classes should start with a capital). Variables should start with a lower case letter and then be Camel case. All upper case implies a constant or preprocessor defined value.