NullReferenceException: Object reference not set to an instance of an object

Im getting this error and dont know how to fix it.

Script A =

var other : einlesen;

function test(){

	other.sprache = "de";
	other.sprache2();
	weiterbutton = other.weiterbutton;
	textbox1 = other.textbox1;

}

Script einlesen =

var sprache = "";
var fileName = "";
var weiterbutton = "";
var textbox1 = "";
var sprachdatei2 = new Array();

function sprache2(){
...
    }
}

error occurs on other.sprache = “de” and other.sprache2()

There is nothing here that initializes ‘other’. You need to select ‘Script A’ and then drag and drop the game object that has the einlesen script attached to onto the ‘other’ variable in the inspector. Or you can use something like GameObject.Find() in Start to find and initialize that variable.

See:
http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Heya :slight_smile: well the problem is i dont want to attach the script on any object, cause it should be a class that reads a txt for me and i just dont want to copy & paste all the text again and again so i just want to give the sprache() some instructions to handle with and after this i want 2 variables back.