How do I correctly use SendMessage?

I am trying to create a Boss fight scenario in a topdown shooter in which when the player crosses a boundary, a number of enemies are instantiated, and then when the number of enemies reaches zero, then the boss fight is over.

I am trying to use Unity’s sendmessage things but they aren’t working and I dont know why. I tried to write this in chronological order but it might be a little messed up.
Thanks in advance!

//CrossBoundary Script
   function OnTriggerExit(other : Collider){
    
    //player crosses line
        if (other.gameObject.collider.tag == "Player"){
        SendMessage("BossStart");
        SendMessage("Enemies");

//Sets BossFight to true on enemy script
function BossStart(){

BossFight = true;


}

//death function on enemies
function Death(){

	dead = true;
	Destroy (gameObject);
	Instantiate(EnemyDiesParticles, transform.position, transform.rotation);
	dead = false;
	
	if (dead == true && BossFight == true){
	
		SendMessage("EnemyCounter");
	
	}

	

//"gamemaster"
function Enemies () {

	for (var i = 0; i < BossNumber; i++)
		Instantiate(Enemy, BossSpawn.position, Quaternion.identity);
	enemyCount = BossNumber;
	

}

You’re sending message to the gameobject which contains this script. If I understood right - you think that SendMessage sending message to all of the gameobjects in scene, but it’s sending message to all components on gameobject.

You are calling the SendMessage() from the CrossBoundary script to the same script itself.You should call the SendMessage() from the CrossBoundary script to the enemy script.

//CrossBoundary Script
function OnTriggerExit(other : Collider)
{
  //player crosses line
  if (other.gameObject.collider.tag == "Player")
  {
    Enemy.gameObject.SendMessage("BossStart");
    Enemy.gameObject.SendMessage("Enemies");
   }
}

If you are having more than one enemy,use tags to find the eneimes and sendmessage to them.

//CrossBoundary Script

//The array of enemy gameobjects
var Enemies;

function OnTriggerExit(other : Collider)
{
  //player crosses line
   if (other.gameObject.collider.tag == "Player")
   {
      //Get all objects with  tag " Enemy"
      Enemies = GameObject.FindGameObjectsWithTag ("Enemy");

      for (var Enemy in Enemies)
      {
        Enemy.gameObject.SendMessage("BossStart");
        Enemy.gameObject.SendMessage("Enemies");
      }
   }
}