Particle emitter controller

I am getting this error message on a simple script that is supposed to control the emitting of a particle.

MissingReferenceException: The object of type 'ParticleEmitter' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
whistleSteamController.Update () (at Assets/whistleSteamController.js:12)

and this is the script I made:

var steamEmitter : ParticleEmitter;

function Update()

{
	if (Input.GetButton("Fire1")){
		animation.Play("open");
		steamEmitter.GetComponent(ParticleEmitter).emit = true;
	}
	if (Input.GetButton("Fire2")){
		animation.Play("close");
		steamEmitter.GetComponent(ParticleEmitter).emit = false;
	}

}

The problem was you are trying to access a destroyed object’s component, without checking if it exists are not.

var steamEmitter : ParticleEmitter;

function Update()

{
    if (Input.GetButton("Fire1")){
       animation.Play("open");
    
       if(steamEmitter!=null)
             steamEmitter.GetComponent(ParticleEmitter).emit = true;
    }
    if (Input.GetButton("Fire2")){
       animation.Play("close");
    
       if(steamEmitter!=null)
            steamEmitter.GetComponent(ParticleEmitter).emit = false;
    }

}