Destroying enemy only partially works

Jumping over enemy once changes color, jumping over it a second time destroys the enemy, then the enemy re-spawns, those parts work. The problem is, the number of times jumped doesn’t reset back to zero, so after the enemy re-spawns jumping over the enemy once destroys it. Revering to starting color after enemy is destroyed works too.

How do I do it so you need to jump over an enemy twice each time it re-spawns?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//Destroy enemy 2 after jumping twice, jumping once turns him to blue

public class DestroyEnemy2 : MonoBehaviour //enemy 2
{
    [SerializeField] Transform Enemy2Respawn;

    int hitCount = 0;
    private Renderer rend;
    private Color colorToTurnTo = Color.blue;
    private Color colorToTurnToo = Color.grey;  // after destroying enemy, changes color back to original


void Start()
   

    {
        rend = GetComponent<Renderer>();
        rend.enabled = true;
        Physics2D.queriesStartInColliders = false; //since ray starts from the enemy...
                                                   //...game object, this will make it so it won't...
                                                   //...destroy itself right when the game starts
    }

    bool waitingForFirstHit = true;
    bool waitingForSecondHit = false;
    float timeDelay = 0.2f;

void Update()
    {
       
        RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, Vector3.up, 5);

        if (hitInfo.collider.gameObject.tag == "Player")
        {
            if (waitingForFirstHit)
            {

                ChangeColor();
                waitingForFirstHit = false;
                waitingForSecondHit = true;
            }
            else if (waitingForSecondHit && timeDelay < 0)//when it's >0 it causes it to be destroyed after one jump.  when its <0 , it just changes color and waits till you do a second jump
            {
                destroyEnemy();
                transform.position = Enemy2Respawn.position;
                Score.scoreValue += 50;
            }
        }

    if (waitingForSecondHit)
        {
            timeDelay -= Time.deltaTime;
        }
    }

    void ChangeColor()
    {
        rend.material.color = colorToTurnTo;
       
    }

    void ChangeColorr() //turn back to original after destroying enemy
    {
        rend.material.color = colorToTurnToo;

    }

    void destroyEnemy()
    {

        {
            Destroy(GameObject.FindWithTag("Enemy2"));
            ChangeColorr();

         }

    }

When you do the destroyEnemy() you are not resetting your bool flags, or resetting your hitCounter, which I don’t think is even being used here.

I forgot to remove “hitCounter” lol.

Hope I dont need a while loop in there. I tried various ways to reset the bools but none worked. I tried both of the bools true and false on line 51, didnt work. Then I tried them on line 78, didnt work. I tried just one, then I tried using both of them, those also didnt work.

Time to start using Debug.Log() to print the values of the bools out, and compare what they are when it works and when it doesn’t. If they’re the same, it’s something else. Keep looking for other sources of statefulness.