Object collision trigger not enabling/disabling script properly

Ok so what im trying to do is right a script that when my FPS controller comes in contact with a box that is set in a position it will enable or disable a script on a 3rd party object. Specifically this script is for the player walking through a trench when he passes through the box that has its mesh renderer turned off it will activate the AI script of an enemy that is waiting around the corner, thus essentially making a trigger that gets the enemy to run around the corner and try and kill the FPS controller. So far this is what i've come up with:

`var Target : GameObject; function OnTriggerEnter (other : Collider) { Target.GetComponent(SpawnTest).enabled = false; }`

This code gives me the error "object reference not set to an instance of an object" Any help in this frustrating matter would be greatly appreciated.

Either the Target doesn't have a SpawnTest component, or the Target variable is null (has not been set).

Try putting in some Debug.Log statements like this:

var Target : GameObject;

function OnTriggerEnter (other : Collider) {
    Target.GetComponent(SpawnTest).enabled = false;

If the first Debug statement is null, it means the Target has not been set. If the second is null, the Target object doesn't have a SpawnTest component.

To go along with Stelimar's answer: you probably forgot to drop in the Enemy's object in the Target Slot in the editor. It will say None(Transform) or something in the Inspector.

If this is not the case, have a look at the script's name in the Project Pane. any misplaced capitals will also lead to a NullReference error.