Cooldown wont apply

Why wont my cooldown be applyed?

if(Fire.mobileFire)
        {
            cannonFire();
        }


void cannonFire()
    {
        if (!CD && ballAmount > 0) {
            CD = true;
            Transform bullit = (Transform)Instantiate(CannonPrefab, GameObject.Find("spawnPoint").transform.position ,transform.rotation);
            bullit.GetComponent<Rigidbody2D>().AddForce(transform.right * CannonPower);

            ballAmountVisual--;
            //GetComponent.<AudioSource>().Play();
            StartCoroutine(Delay (CDTimer));
            CD = false;
            ballAmount--;
        }
    }

    void cannonPreviewFire()
    {
        if (activatePreview.preview) {
            Transform bullit = (Transform)Instantiate (CannonPreviewPrefab, GameObject.Find ("spawnPoint").transform.position, transform.rotation);
            bullit.GetComponent<Rigidbody2D> ().AddForce (transform.right * CannonPower);
        }
    }


    void StartGameOver ()
    {
    Delay(5);
    //GameOver.GameOver = true;
  
    }

IEnumerator Delay(int Timer) {
  
    yield return new WaitForSeconds(Timer);
  
}

Starting a coroutine does not pause a normal function. A coroutine has a time delay only within the coroutine itself.

So how do i make the delay?

Move “CD = false;” as the last line in the coroutine.

Thanks :wink: