Debug.Log error

Sorry this is a total newby question. I am doing my first scripting, when I click on a cube (GameObject) it should inform me “this object was picked” my script looks like this:

function OnMouseDown () {
Debug.Log (“This object was picked”);
}

I get a message saying “The Referenced script on this behaviour is missing!” Can you tell me what I am doing incorrectly?

Look on that object in the inspector panel where the script should be.

If it says [checkbox]Mono Behaviour and then under that it says Script None(Mono Script) then your script isn’t assigned for some reason. You might have deleted it, then made a new one with the same name and expected it to be there still, or something… whatever happened, it’s missing, so click on that script area and assign one to the slot, or drag the one you want over there from the project panel and drop it on.

Edit :

You should re-title your question for search-purposes also, since this isn’t an error with Debug.Log.

Added Note :

It could be any object in your scene missing a script for some reason like I said above, it isn’t necessarily the object you’re trying to mouse-click on. Maybe you deleted a script somewhere and still have another object in the scene that had it assigned to it, so now it doesn’t have it anymore.

Attach the Object to the script in the inspector. Make sure all the objects are attached to the script.

Good luck!