instantiate problem

hello every1: i wrote a code like this:

var prefab : GameObject;
function Update () 

{   
    if (Input.GetMouseButtonDown(0))
    {   
        var prefab : Transform;
        var i : int;
        for(i=0;i<2;i++)
        {
        Instantiate (prefab);
        }
    }
}

when we run the function we take this error message :

" NullReferenceException: The prefab you want to instantiate is null. UnityEngine.Object.Instantiate (UnityEngine.Object original) uretme.Update () "

how can i solve this problem?take you for attention...

For a summary, take a look at the following code comments:

var prefab : GameObject;  // <--This value must be assigned. (Via editor or script.)
function Update () 

{   
    if (Input.GetMouseButtonDown(0))
    {   
        var prefab : Transform;  // <--This variable is shadowing.  Remove the line.
        var i : int;
        for(i=0;i<2;i++)
        {
        Instantiate (prefab);
        }
    }
}

Some more details:

The "prefab" variable is declared in two locations in your code. The Transform version is shadowing the GameObject version. So when you call "Instantiate(prefab)" it will select the Transform version, which is always null.

After removing the line that declares the Transform version of the variable, if you are still having a problem, take a look at the game object that has the script attached. Does the prefab variable have an assignment? If not, you'll need to get one assigned.

I haven't told unity what you want to appear.

Drag a prefab onto Prefab in the inspector.

I think this question will be help you

http://answers.unity3d.com/questions/15764/nullreferenceexception-the-prefab-you-want-to-instantiate-is-null