Object Referance is not set to an instamce of an Object

I am trying to change a boolean in a different script On collision here is the code:

var script : Bullet;

function OnCollisionEnter(collision : Collision) {

if(collision.gameObject.tag == "Weapon1"){
script.gun1 = true;
script.gun2 = false;
Debug.Log("cgfbkml");
}

if(collision.gameObject.tag == "Weapon2"){
script.gun1 = false;
script.gun2 = true;
Debug.Log("cgfbkml");
}

}

When i collide with the object i get the error message, the script i am getting the Boolean from is

var bulletSpawn1 : Transform;
var bulletSpawn2 : Transform;
var gun1 : boolean = true;
var gun2 : boolean = false;

function Update () {
GunsAndBullets();
}

function GunsAndBullets(){

	if(gun1 == true  gun2 == false){
		if(Input.GetKeyDown(KeyCode.Mouse0)){
		Instantiate(bulletSpawn1,transform.position, transform.rotation);
		}
	

}

	if(gun2 == true  gun1 == false){
		if(Input.GetKey(KeyCode.Mouse0)){
		Instantiate(bulletSpawn2,transform.position, transform.rotation);
		}
	
}

}

Any solutions thanks.

First, use Debug.Log properly.

Also you have not told us how you set var script : Bullet;.

If i was debugging the issue i would do this:

var bulletSpawn1 : Transform;

var bulletSpawn2 : Transform;

var gun1 : boolean = true;

var gun2 : boolean = false;

 

function Update () {

GunsAndBullets();

}

 

function GunsAndBullets(){

 

    if(gun1 == true  gun2 == false){

        if(Input.GetKeyDown(KeyCode.Mouse0)){
        Debug.Log(bulletSpawn1);
        Instantiate(bulletSpawn1,transform.position, transform.rotation);

        }

    

 

}

 

    if(gun2 == true  gun1 == false){

        if(Input.GetKey(KeyCode.Mouse0)){
Debug.Log(bulletSpawn2);
        Instantiate(bulletSpawn2,transform.position, transform.rotation);

        }

    

}

 

}

and

var script : Bullet;

 

function OnCollisionEnter(collision : Collision) {

 Debug.Log(script);

if(collision.gameObject.tag == "Weapon1"){

script.gun1 = true;

script.gun2 = false;

}

 

if(collision.gameObject.tag == "Weapon2"){

script.gun1 = false;

script.gun2 = true;

}

 

}

This would help me find what can not be found.