Why doesnt this bool take effect even though it does change?

Hello, i have been writing some code to make an attack with a cooldown and specific duration, this is the code

   if (Input.GetKeyDown(KeyCode.E) && ableToAttack)
            ableToAttack = false;
            toggleAttack = !toggleAttack;
            burning = toggleAttack;
            if (toggleAttack == false)

The code works as intended, the bool toggleAttack changes from false(its set value) to true when pressing E and it also turns to false when the 2 seconds the attackDuration corountine has get to 0, but the gameobjects attack and attackParticles dont change to false, they remain in the scene when they should have been turned off, any idea as to why this is happening? Any help would be appreciated

You are not calling SetActive(false) on your gameobjects after these 2 seconds pass, so I suggest you call it in your “attackDuration” method, just after setting “toggleAttack”.