Defining a variable in another script?

Hello. These are the scripts for selecting the options for my game (mode, difficulty, etc.). How it works is that the menu are a bunch of toolbars. Each toolbar option selected represents a number, that number represents a number in a different script, and that other script contains the functions that start the options (like "Standard difficulty=true")

If I define something to happen in the script that has the toolbat GUI like this, the other variable (in this case, "Score") works, Its changed to whatever is defined.

var ModeInt = 0;
var ModeStrings : String[] = [];    

function OnGUI() 
    ModeInt = GUI.Toolbar (Rect (240, 270, 500, 50), ModeInt, ModeStrings);

function Update (){
if (ModeInt==2) {Stats.Score=1000}


I then tried to make a variable in the GUI script affect a variable in another script (in this case the "ArcadeOptions" script) :

if (ModeInt==0) {ArcadeOptions.Mode =2;}

(Here is the ArcadeOptions Script)

static var Mode = 5;

function Update (){
if (Mode ==0) {Stats.Score=1000;}


and it works, the Score value is changed.

The problem happens when I try to have the "ModeInt==" something other than 0(so that other buttons can affect the "ArcadeOptions" script). No matter what the element of that toolbar is, if it is not 0, nothing happens in the other script, what is going on(I am getting no errors from unity)?


You need to create a reference to the instance of the first script.

var scriptWithMode : ScriptWithModeInt; // drag-and-drop from inspector

function Update() {
  if (scriptWithMode.ModeInt == 0) {
    // foo