How can I fix this so it sends the messages to the game objects with the tag?

hello! I know that questions similar to this have been answered but I am kind of new to C# coding so I don’t understand too much on how to fix my code so it sends the messages to the enemies, if you can help me it would be really helpful but here is my code:

public static bool GameIsPaused = false;

public bool isResumed = true;

public GameObject pauseMenuUI;
GameObject[] AIEnemies;

private void Start()
{
    AIEnemies = GameObject.FindGameObjectsWithTag("EnemyAI");
}

private void Update()
{
    if(Input.GetKeyDown(KeyCode.Escape))
    {
        if(GameIsPaused)
        {
            Resume();
        }
        else
        {
            Pause();
        }
    }
}

void PauseandResumeAI ()
{
    if(isResumed)
    {
        foreach (GameObject enemy in AIEnemies)
        {
            enemy.SendMessage("Pause");
        }
    }
    else if(!isResumed)
    {
        foreach (GameObject enemy in AIEnemies)
        {
            enemy.SendMessage("UnPause");
        }
    }
}

public void Resume ()
{
    pauseMenuUI.SetActive(false);
    Time.timeScale = 1f;
    GameIsPaused = false;
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
    isResumed = true;
    GameObject.Find("MainCharacter").SendMessage("EnableHealth");

}
void Pause()
{
    pauseMenuUI.SetActive(true);
    Time.timeScale = 0f;
    GameIsPaused = true;
    isResumed = false;
    GameObject.Find("MainCharacter").SendMessage("DisableHealth");
}

I would love it if you could help me, thanks!

I think you might have wanted to get the script on your enemyObjects that contains the SendMessage Method

public static bool GameIsPaused = false;
 public bool isResumed = true;
 public GameObject pauseMenuUI;
public EnemyObjectScript[] enemyScripts; // The name of your enemyObjects script

 private void Start()
 {
     GameObject[] AIEnemies = GameObject.FindGameObjectsWithTag("EnemyAI");
     enemyScripts = new EnemyObjectScript[AIEnemies.Length];

    for(var i=0;i<AIEnemies.Length;i++)
   {
     enemyScripts *= AIEnemies.GetComponent<EnemyObjectScript>();*

}
}
private void Update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
if(GameIsPaused)
{
Resume();
}
else
{
Pause();
}
}
}
void PauseandResumeAI ()
{
if(isResumed)
{
foreach (EnemyObjectScript enemy in enemyScripts)
{
enemy.SendMessage(“Pause”);
}
}
else if(!isResumed)
{
foreach (EnemyObjectScript enemy in enemyScripts)
{
enemy.SendMessage(“UnPause”);
}
}
}

Try this. Haven’t tested it so idk

 void PauseandResumeAI ()
 {
     if(isResumed == true)
     {
         foreach (GameObject enemy in AIEnemies)
         {
             enemy.SendMessage("Pause");
         }
     }
     else if(isResumed == false)
     {
         foreach (GameObject enemy in AIEnemies)
         {
             enemy.SendMessage("UnPause");
         }
     }
 }