Check For MissingReferenceException

I have an AI that is trying to destroy a target. I have a function called Evade(). If target is null, then perform Evade(). But the problem is when the AI destroys it’s target, the target variable doesn’t become null, it becomes a MissingReferenceException. The Evade() function is never called, and it doesn’t look for a new target. So I need, not only to check if target is null, but if it’s missing. How do I do that? I tried this :

if(!target || target == MissingReferenceException){
			Evade();
			FindTarget();
		}

I get an error saying that it’s not a value, type, variable, or method group. What should I use instead of MissingReferenceException?

Well, you could do something like:

var targethealth : int;
var targetdestroyed : boolean;

if (targethealth <= 0)
{
targetdestroyed = true;

}

if (targetdestroyed = true)
{
Evade();
FindTarget();

}

Hope I’ve helped =)