calling a script from a gameobject - same script or separate script?

I have a GUI texture that I want to call a function in a script. The other script animates the GUI texture and changes scene / does some other stuff.

Here’s an example of the sort of code I’m using:

//script that animates a GUI Texture gameobject and controls the active screen "titleScreen.js"

var btnSettings : GameObject;
var settingsScreen : GameObject;
var titleScreen : GameObject;

function OnEnable(){
	//stuff
}

function exitTitleScreen(){
	/stuff
}

function SwitchToSettingsScreen(){
	exitTitileScreen();
	titleScreen.SetActiveRecursively(false);
	settingsScreen.SetActiveRecursively(true);
}

I’d like to make it so that the GUI Texture is able to run the function SwitchToSettingsScreen(), I tried to make a new script, place it on the gameobject in my hierarchy:

//Button script on GUI Texture "button.js"

function OnMouseUp(){
			titleScreen.SwitchToSettingsScreen();
			}

Unfortunately I get the following error:

An instance of type ‘titleScreen’ is required to access non static member ‘SwitchToSettingsScreen’.

Ideally, I’d like the extra script I’m making for the button to just be in the titleScreen.js and not have to make something like button.js everytime I want to use a button to control a script.

Well, I’m stumped. I’ve also asked this over at unity Questions, to no avail unfortunately. What would be the best way to access the functions in titleScreen.js from a GUI Texture gameobject click / tap?

not sure if this is the right way about doing things but I just solved this by changing button.js to:

var titleScreen : titleScreen;

function OnMouseUp(){
			titleScreen.SwitchToSettingsScreen();
			Debug.Log("Settings button");
			}

And then drag dropping the gameboject with the titlescreen.js code into the inspector for that new var.

Seem like a strange way to go about things… obviously have a long way to go. Hope this helps anyone with the same problem.