missing gameobject ≠ Null?

I made a script not too long ago, and it’s supposed to detect if the variable ‘target’ is empty. When the object is destroyed, however, it says missing gameobject, and null no longer works. Can anyone tell me how to detect a missing gameobject? Here is the script: (asterisks where this part of the script is)

var ifenemy : boolean;

var Health : int;

var Deadreplace : Transform;

var target : Transform; //the enemy's target

var tarpos : Vector3;

var moveSpeed = 50; //move speed

var rotationSpeed = 3; //speed of turning

var thispos : Vector3;

var inrange = false;
var myTransform : Transform; //current transform data of this enemy
function Awake()
     myTransform = transform; //cache transform data for easy access/preformance
function Start()
     Health = 100;
**function Update () {
if(ifenemy == false){
target = GameObject.FindWithTag("Enemy").transform; //target the player
if(ifenemy == true){
target = GameObject.FindWithTag("GoodGuy").transform; //target the player
if(target != null){
    inrange = false;
    shootobj.GetComponent(AAShoot).canshoot = false;
tarpos = target.position;
thispos = transform.position;
if(Vector3.Distance (thispos, tarpos) < 175){
            inrange = true;
            shootobj.GetComponent(AAShoot).canshoot = true;
    myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
    Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
                //move towards the player
    myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
    if(Vector3.Distance (thispos, tarpos) > 175){
    inrange = false;
    shootobj.GetComponent(AAShoot).canshoot = false;

function OnCollisionEnter (collision:Collision)
    if (collision.gameObject.tag == "Damage")
    Health -= 20;

You continue to reference target outside of the null check. Simply paying attention to which line the error occurs at (or double clicking the error in the console) will let you know exactly where the problem is.

At line 40 you check if the target is not null, but at lines 45 and 53 you reference it outside of the null check.

What you might consider doing is the following on line 40/41:

if (target == null)

Then do everything that you would do if the target was not null. Also, properly format your code. It helps a lot when debugging things, plus it reflects how much you care about your own work.