So many script problems. Please help, urgent!

Hi there. I am currently trying to create an animation trigger, and the script I see everyone use is…

using UnityEngine;

public class ActivateTrigger : MonoBehaviour {
	public enum Mode {
		Trigger   = 0, // Just broadcast the action on to the target
		Replace   = 1, // replace target with source
		Activate  = 2, // Activate the target GameObject
		Enable    = 3, // Enable a component
		Animate   = 4, // Start animation on target
		Deactivate= 5 // Decativate target GameObject
	}

	/// The action to accomplish
	public Mode action = Mode.Activate;

	/// The game object to affect. If none, the trigger work on this game object
	public Object target;
	public GameObject source;
	public int triggerCount = 1;///
	public bool repeatTrigger = false;
	
	void DoActivateTrigger () {
		triggerCount--;

		if (triggerCount == 0 || repeatTrigger) {
			Object currentTarget = target != null ? target : gameObject;
			Behaviour targetBehaviour = currentTarget as Behaviour;
			GameObject targetGameObject = currentTarget as GameObject;
			if (targetBehaviour != null)
				targetGameObject = targetBehaviour.gameObject;
		
			switch (action) {
				case Mode.Trigger:
					targetGameObject.BroadcastMessage ("DoActivateTrigger");
					break;
				case Mode.Replace:
					if (source != null) {
						Object.Instantiate (source, targetGameObject.transform.position, targetGameObject.transform.rotation);
						DestroyObject (targetGameObject);
					}
					break;
				case Mode.Activate:
					targetGameObject.active = true;
					break;
				case Mode.Enable:
					if (targetBehaviour != null)
						targetBehaviour.enabled = true;
					break;	
				case Mode.Animate:
					targetGameObject.animation.Play ();
					break;	
				case Mode.Deactivate:
					targetGameObject.active = false;
					break;
			}
		}
	}

	void OnTriggerEnter (Collider other) {
		DoActivateTrigger ();
	}
}

My problem is that I get a whole load of errors.

Is everyone able to help me please?

Thanks.

You have a simple syntax problem it looks like, a missing token or too many tokens. Go to the first error you see in the build window. That’s probably the one that’s causing the others.

The code looks find except one thing that isn’t clear. What is DestroyObject()?
I guess you want Destroy()

You also might want to store the new object returned by Instantiate in the targetGameObject variable after you destroyed the old one, but i’m not sure if that’s what you want. If so i would do it like this assuming that target and source are not the same object:

          if (source != null) {
             var oldTransform = targetGameObject.transform;
             targetGameObject = Object.Instantiate (source, oldTransform.position, oldTransform.rotation) as GameObject;
             Destroy(oldTransform.gameObject);
          }

edit
Just zoomed into your “screenshot”. I can’t really read much of it, but i clearly can read that your filename is .JS while your script is C#. All those errors have an error id starting with BCExxxx which comes from the Boo / Unityscript crosscompiler. C# error ids start with CSxxxx.

So you might want to rename your file into .cs