CancelInvoke not working

So my game has a spawn manager that spawns enemies using InvokeRepeating, and I’m trying to set it so that when a bool from my player script becomes false, a cancelinvoke method is called out and the spawn manager stops, but its not working. Am I doing something wrong?

my code looks like this:

void Start()

{
    playerOn2 = GameObject.Find("Player").GetComponent<PlayerController>().playerAlive;
    if (playerOn2 == true)
    {
        InvokeRepeating("SpawnTopRightDoor", 2, 4);
        InvokeRepeating("SpawnTopLeftDoor", 4, 3);
        InvokeRepeating("SpawnBottomRightDoor", 15, 4);
        InvokeRepeating("SpawnBottomLeftDoor", 12, 4);
    }
        
    

}

// Update is called once per frame
void Update()
{
    if (playerOn2 == false)
    {

        CancelInvoke();
    }
}

@Lukipop My best guess so far is that your boolean is not getting false to call the CancelInvoke() method you should try printing debug logs to check.