Refenced script on this behavior is missing?

I am getting this error twice every time I start my game. It isn't a red error that prevents you from starting, it's grey and doesn't do anything when I click on it. I don't know why it keeps appearing, but my script is not working how I thought it would. It was supposed to draw gui textures (which is working fine) but on the first OnGUI if statement, the rotation is not working how I thought. It is only moving up and down (more diagonally than straight) as I turn my character. The error is:

The refenced script on this Behavior is missing!

I have no idea why this is happening, or why my script is only moving the texture diagonally instead of rotating it around its center like I wanted. For reference purposes, here is my script:

var camera1 : Camera;
var camera2 : Camera;
var camera3 : Camera;
var openButton : Texture2D;
var closeButton : Texture2D;
var mapMarker : Texture2D;
var compass : Texture2D;
var mapSkin : GUISkin;
var characterTransform : Transform;
var screenPos : Vector3;
var playerDirection : float;
var pivotPoint = Vector2(66.5,386.5);

function Update () {
    if (camera2.enabled) {
    screenPos = camera.WorldToScreenPoint (characterTransform.position);
    }
}

function OnGUI() {
    GUI.skin = mapSkin;
    if (camera1.enabled) {
        playerDirection = characterTransform.transform.rotation.y;
        GUIUtility.RotateAroundPivot(playerDirection,pivotPoint);  
        GUI.DrawTexture(Rect(1145,3,290,290),compass);
        GUI.DrawTexture(Rect(1275,133,30,30),mapMarker);
        if (GUI.Button(new Rect(1115,270,50,50),openButton)) {
            camera1.enabled = false;
            camera2.enabled = true;
            camera3.enabled = false;
        }
    }
    if (camera2.enabled) {
        GUI.DrawTexture(Rect(screenPos.x - 12,730 - screenPos.y,20,20),mapMarker);
        if (GUI.Button(new Rect(1250,100,100,100),closeButton)) {
            camera1.enabled = true;
            camera2.enabled = false;
            camera3.enabled = true;
        }
    }
}

function Start () { 
    camera2.enabled = false; 
} 

In my case it was not a game object in the Hierarchy, but its prefab in the Project.

The game object on the scene was ok and contained no attached scripts. Its prefab, however, did contain the script which I had recently deleted.

I found this mistake only by deleting objects one by one in the scene, then checking the log for ‘referenced script’ warning.

Hope this helps.

like it says : one (or more) of your gameobjects in the scene is (are) missing an attached script. Look through your gameobjects in the scene and look for any script that reads None (Mono Script) where the script should be. Delete those or attached the correct script and you get rid of that error message. If you click the error message once it should highlight the gamobject in question in the Hierarchy if I'm not mistaken.

I fixed this by selecting all (CTRL-A) in the heirachy view and copy then delete.

then click in the scene view and CTRL-A and delete.

then paste (CTRL-V) and all was fixed

Make a prefab of that gameObject which has missing script. And then click on the prefab. You will find them. Remove those missing scripts and apply that prefab in Heirarchy and remove the previous One. This is how I got rid of this problem

In one case, I had created a script with a misspelled name (Ex: PLayerCtrl - with a uppercase L) and the C# Class is named such. I corrected the script name within the editor to ‘PlayerCtrl’, the file name had changed, but still the Class name was the old ‘PLayerCtrl’.

Naturally fixing the class name fixed this error. Hope this will help someone. Thanks.

yeah ctrl+A, ctrl+C, delete, ctrl+V fixed it for me too.

when i double clicked the error message monodevelop would blink on my taskbar, but nothing would be highlighted in unity or monodevelop.

weird.

thanks for the tip milali

So I got this error and found out what is the reason it shows up. I don’t say it is THE only reason but obviously is one reason.

I had a script attached to an object, I deleted the script from my project directory.
And BAM, comes the warning.

Problem is Unity deletes the script from you directory but does not delete the script as a component of the prefabs, instead it shows in the inspector as MonoBehaviour and an empty slot. So just remove component and the warning goes.

I searched this issue last night and looked through the top 6-7 posts, tried a few things, then slept on it and resolved my own version this morning. Judging from all the others that trip up on it I thought maybe if I put mine here on the top result others will see it. I tried the scary CTR-A, CTR-C, DELETE! but it didn’t help me and a careful scrutiny of the scripts turned up nothing. I hadn’t deleted or renamed any. So I looked at each object in the hierarchy carefully and what I found was not directly script-related. I found a stray audio clip component on the root parent of the FPC. (It is called by a script in its proper place). Removed it. No more error. Now it happens to be a clip that I have on there a couple-three or so children down on a particle object, so it may have been a result of thoughtless dragging and dropping. Lesson is, yes, when you get this one you have to carefully examine every part of every object.

Here also I’ll put a general note of thanks to the helpful Unity community. Looks like I’m hitting the hurdles others have encountered and solutions can be had. On the right track.

first,click on the script you want to delete.then,press the delete button above the backspace button

I was able to fix it with this tool:

if you have a complex scene, it can practically impossible to find what may be causing this.
This tool found it right away and fixed it.

Mine was a name typo in the Class. didn’t get a warning but figured it in the end. whoops

One issue that could cause a “The referenced script on this Behavior is missing!” error, particularly for newbies, such as myself, is creating a script and naming it, which gives the class in the script the same name as the script name, and then pasting in copied material from sample code which will have a different class name. To correct this problem, simply change the name of the pasted-in sample code’s class name to that of the script file that you have created. Yeah, sure, everybody knows that, but not told, rube that I am, I didn’t. Sample code, particularly in the Unity Scripting and Manual Help Files should point this out for rubes such as myself.

You can find missing scripts By this script:
http://wiki.unity3d.com/index.php?title=FindMissingScripts

This also may happens if you make a mistake naming the file and the script:
Example:

filename: DestroyByBoundary

Script : public class DestroyByBoudary () { … }

At this case, “n” is missing.

I had a very similar case but mine which none of anything that has been mentioned solved.
I had created a static hierarchy in a scene. Of which I’d deleted objects from which contained scripts (missing?). I was getting 999+ missing referenced scripts from this. Turns out these objects were still loading when the scene was additively loaded.

Unticking static on the hierarchy and then reticking again fixed the issue!

Corrupt scene file. Recopy all objects.

I got a lot of “The referenced script on this Behaviour (Game Object ‘’) is missing!” warnings and couldn’t find any misbehaving object in the scene or prefabs with “FindMissingReference” scripts or paid tools from the asset store. Eventually the problem was a corrupt scene file. Solution: Create a new scene, load it into the bogus scene and copy all objects. You should also check the references of the scripts and UI input handling. Some references were lost in copyation and I had to remove and readd the EventSystem o_O.