Why can't I call function from another script?

Hi people, just wondering if you could have a look at my script. I’m trying to call over a function from another script and it keeps giving me the error that it is not a member of “Object”.Here’s my scripts

Score Script:

function CheckValueOfScore(){
	//Debug.Log("Score equals "+score);
	if (score > 299)
	waterMarkObject = GameObject.FindWithTag("GUITime");
	countdownScript = waterMarkObject.GetComponent(Countdown);
	currentGUITime = countdownScript.HandOverGUITime();
	Debug.Log("ShootScript reads GUITime as "+currentGUITime);
	Debug.Log("Countdown reading as "+countdownScript);
	yield WaitForSeconds (3);
	Debug.Log("Game over");

Timer script

var startTime : int;
private var restSeconds : int;
private var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;
var countDownSeconds : int;
var Text;
var customGuiStyle : GUIStyle;
var GUITime :int;

function Awake() 
    startTime = Time.time;

function OnGUI()
Debug.Log("Real GUITime is "+GUITime);
GUITime = Time.time - startTime;
    restSeconds = countDownSeconds - GUITime;

    //display messages or whatever here -->do stuff based on your timer
    	if (restSeconds == 60) 
       	print ("One Minute Left");
   	 	if (restSeconds == 0) 
        print ("Time is Over");
        //do stuff here

    //display the timer
   	 	roundedRestSeconds = Mathf.CeilToInt(restSeconds);
    	displaySeconds = roundedRestSeconds % 60;
    	displayMinutes = roundedRestSeconds / 60; 

    	Text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds); 
    	GUI.Label (Rect (400, 25, 100, 30), "Time Remaining: " +Text, customGuiStyle);
function HandOverGUITime(){
	Debug.Log("inside HandOverGUITime()"); 
	return GUITime;

Any help would be lovely :smiley:

To address the question, even though it seems that you are getting a lot of good hints on ‘other’ topics. :slight_smile:

To call a function in ScriptA from another ScriptB you will have to let ScriptA know about ScriptB. Like so in ScriptA:

public var scriptKeeper : SctiptB;

function Start ()
	scriptKeeper = GameObject.Find("NameOfObjectWithScriptB").transform.GetComponent<"ScriptB">();

You would then be able to use


from within ScriptA, provided that the function is public.

I admit that I did not take the time to look through your scripts closely, thus from the question title this seemed to fit as a posible solution.

I hope that this can help you out a bit.