Object Refrence not set to an instance of an object.

I’m having some issues that I can’t seem to identify in my code, I have made a game where I can press a button then begin placing boxes which will “fire” fireworks from then once I press another button, however when I instantiate a firework at the position of a box and try to apply a velocity to it (It has a Rigidbody2D component) I get the “NullRefrenceException: Object not set to an instance of an object”

Here’s some code:

#pragma strict
var boxPic : Texture2D;
var fwPic : Texture2D;
public var fwBox : GameObject;
var fw : GameObject;
var coords : Vector3;
var canCreate : int = 0;
var rockets : int = 0;
public var speed : float = 2.0f;
public var boxes : GameObject[];





function Start(){
//boxes = new Array();
boxes = GameObject.FindGameObjectsWithTag("Spawner");
}

function Update(){
boxes = GameObject.FindGameObjectsWithTag("Spawner");
coords = this.GetComponent(ClickAndPlace).crCur;
}

function launch(){
for (var box : GameObject in boxes){
var Firework : Rigidbody2D = Instantiate(fw, box.transform.position, box.transform.rotation)as Rigidbody2D;
Firework.velocity = new Vector2(0,speed);
}
}

function addBox(){
var NewBox = Instantiate(fwBox, coords, transform.rotation);
rockets++;
}

function OnGUI(){

if (GUI.Button (Rect(Screen.width*(1f-0.3f),Screen.height * (1f-0.1f),64,64),boxPic))
{
canCreate = 1;
}

if (GUI.Button (Rect(Screen.width*(1f-0.23f),Screen.height * (1f-0.1f),64,64),fwPic))
{
launch();
}

}

And here’s the other script it refrences, although I don’t think it is important in this issue.

    #pragma strict
    private var lastObjCor : Vector3;
    private var lastObjRef : String;
    public var cam:Camera;
    public var crCur : Vector3;
    var boxClickLaunch : GameObject; 
    function Start () {
    }
     
    function Update () {
    
    crCur = cam.ScreenToWorldPoint(Input.mousePosition );
	crCur.z = -1;
 
        if (Input.GetButtonDown("Fire1"))
        {
            var hit : RaycastHit2D = Physics2D.Raycast(cam.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
            if(hit != null)
            {

            	
                Debug.Log("object clicked: "+hit.collider.tag);
                lastObjCor = hit.collider.transform.position;
                lastObjRef = hit.collider.tag;
                Debug.Log("object clicked x: "+lastObjCor);
               	Debug.Log("mouse coords: "+crCur);
               	Debug.Log("Tag to String: "+lastObjRef);
               	
               	if(this.GetComponent(fireworkPlacer).canCreate == 1 && hit.collider.tag == "ground")
               	{
               	this.GetComponent(fireworkPlacer).addBox();
               	}
            }
        }
    }

Any help is appreciated, thanks!

Try replacing lines 28 and 29 with:

var Firework : GameObject = Instantiate(fw, box.transform.position, box.transform.rotation) as GameObject;
Firework.rigidbody2D.velocity = new Vector2(0,speed);