How to make two objects collide using "Is Trigger"

I am new to Unity (Currently learning Javascript) and I am currently trying to use the “Is Trigger” option on a sphere tagged “Enemy” to collide with a cube tagged “Player”. The cube can move on the x and z planes and the sphere follows the cube’s path. Once the two collide then the sphere should be destroyed.

My problem is that when the sphere collides with the cube, nothing happens. It will only be destroyed if I move the cube.

This is the script that I have for the sphere:

#pragma strict

var player : Transform;
var moveSpeed = 5;
var maxDist = 10;
 
 
 
 
function Start () {
 
}
 
function Update ()  {
	transform.LookAt(player);
	if(Vector3.Distance(transform.position,player.position) <= maxDist) {
		transform.position += transform.forward * moveSpeed * Time.deltaTime;
	}
		
}

function OnTriggerEnter (other : Collider) {
	
	if (other.tag == "Player") {
		Destroy(gameObject);
	
	} 

}

The behavior you described is not unusual, since trigger colliders are meant to be static. I’m actually surprised that the sphere registers the trigger collision at all, since it itself if the trigger and not the player, and the OnTriggerEnter function is meant to register when the gameobject this function is called from collides with a collider which is set to trigger; Basically, the opposite of your situation. Anyway, I suggest putting the OnTriggerEnter script on the player’s script, and then checking for tag “sphere” or “enemy” or whatever, and then destroying the other gameobject:

function OnTriggerEnter (other : Collider) {
     
     if (other.tag == "Enemy") {
         Destroy(other.gameObject);
     
     } 
 
 }