How to use functions between two scripts

OKAY OKAY, before you go getting mad and closing my question i have tried googleing this and none of them really helped me and just left me confused.
So i want to call the function on this script
#pragma strict

var Health = 100;

function Update () {
    if (Health <= 0) {
        Dead ();
        // call function here
function ApplyTheDamage (theDamage : int) {
    yield WaitForSeconds (0.4); 
    Health -= theDamage;

function Dead () {
    Destroy (gameObject);

and then execute it on this script

#pragma strict

function scoreShow () {
    //execute this function
    Debug.Log("function is initiating");
    gameObject.guiText.enabled = true;
    yield WaitForSeconds(3);
    Debug.Log("yield successful");
    gameObject.guiText.enabled = false;        

function Start () {
    gameObject.guiText.enabled = false;

The two scripts are also on different game objects

You just need to have a script variable that references the other gameobject’s script, and then you just call the function like this:

var otherScript;


You can also use a GameObject variable to reference the whole other GameObject.

var GameObject otherObject;


How you “populate” the script or GO variables is up to you; for example, you could use GameObject.Find or just drag it to the variable’s slot in the inspector.

People are rarely mad when closing questions. This particular question gets closed all the time because it has been answered so frequently and in so many different ways. In fact, it rarely makes it through moderation. Here are two references:

Assuming your other script was named ‘Score’, and the name of the game object with the script was ‘TheScore’. Then you could access the function by:


Note when I did and did not use quotation marks in the above line. That’s important. Note for something that will be executed every frame, it would be better to do the Find() in Start() and cache the reference to the script. Or use a public variable for the script and initialize it by drag and drop.