The referenced script on this Behaviour is missing!

var health1 : Texture2D; //one lives left
var health2 : Texture2D; //two lives left
var health3 : Texture2D; //full health

static var LIVES = 3;

function Update () 
{
    switch(LIVES)
    {
        case 3:
            guiTexture.texture = health3;
        break;

        case 2:
            guiTexture.texture = health2;
        break;

        case 1:
            guiTexture.texture = health1;
        break;

        case 0:
            //gameover script here
        break;
    }
}


var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab: Transform;
private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
    if(hit.gameObject.tag == "fallout")
    {
        dead = true;
        //substract life here
        HealthControl.LIVES -=1;
    }
}

function Update ()
{
    var controller : CharacterController = GetComponent(CharacterController);
    transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
    var forward = transform.TransformDirection(Vector3.forward);
    var curSpeed = speed * Input.GetAxis ("Vertical");
    controller.SimpleMove(forward * curSpeed);

    if(Input.GetButtonDown("Jump"))
    {
        var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity);
        bullit.rigidbody.AddForce(transform.forward * 2000);
    }
}

function LateUpdate()
{
    if(dead)
    {
        transform.position = Vector3(0,4,0);
        gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10);
        dead = false;
    }
}

@script RequireComponent(CharacterController)

After I made this scripts, I get the "The referenced script on this Behaviour is missing! " Warning...

I don't think that this have anything to do with the content of this script. This error occurs when you have a script attached to a gameobject and you deleted, moved or renamed it outside of unity. Unity can't find the related script for the MonoBehaviour component.

If you want to rename or move a script do it always in Unity. To solve your error, just find the component that references this missing script and drag the right script onto the component.

I had this issue recently. For me the message appears when I run the game and it will only highlight the GameObject with the missing script if it is in the current scene.

I was able to load different scenes after running it and I was able to find the offending GameObjects.

If you’re having trouble finding where the error is coming from (sometimes unity doesn’t highlight it, especially in cases where the gameobject is turned off), what works best for me is duplicating the scene where the error appears, and deleting chunks of the duplicated scene, until I get down to the last few gameobjects (run the scene each time you delete something to see if the warning goes away. If it does, then undo and delete other game gameobjects while inspecting the apparent culprit(s)). Once I find the problem, I just remove the component from that game object, save the prefab, and delete the duplicated scene.

In case you get this error, while preloading the next szene with the AsyncOperation : If you have in the preloaded Szene any Objects or components, that are missing, the present scene will print out all the errors of your next preloaded szene. So in that case, it would be better, to check your next szene, otherwise you will never get clear on that.