My script 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;
     
        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();
     
             }
     
        }

I believe this script does what you are trying to achieve. Let me know if it works.

Edit: Changed the script to the final version that solved the issue.

using UnityEngine;

public class MyNewClass : MonoBehaviour
{
    [SerializeField] private int hitMaxAmount = 2;
    public LayerMask WhatCanIHit;

    private const float checkHitDelay = 0.2f;
    private float checkHitTime;
    private bool isCheckHitTime;
    private bool isCheckHit = true;
    private int hitCount;

    void Update()
    {
        // Only check for hits if true
        if (isCheckHit)
        {
            // Use a layer mask to stop this raycast from hitting the base object
            RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, Vector3.up, 5, WhatCanIHit);
            Debug.DrawRay(transform.position, Vector3.up * 5f, Color.red);

            // Check if it's hitting a collider
            if (hitInfo.collider != null)
            {
                // Use CompareTag for better performance
                if (hitInfo.collider.CompareTag("Player"))
                {
                    Debug.Log("Hit count: " + hitCount);
                    isCheckHit = false;
                    isCheckHitTime = false;
                    hitCount++;

                    if (hitCount == 1)
                    {
                        Debug.Log("Got hit once, change color");
                        // Change Color
                    }

                    if (hitCount >= hitMaxAmount)
                    {
                        Debug.Log("Destroy Enemy");
                        // Destroy Enemy and stuff

                        // Reset hit count to let it run again
                        hitCount = 0;
                    }
                }
            }
        }

        if (!isCheckHitTime)
        {
            checkHitTime += Time.deltaTime;
            if (checkHitTime >= checkHitDelay)
            {
                Debug.Log("You can hit again");
                isCheckHitTime = true;
                isCheckHit = true;
                checkHitTime = 0.0f;
            }
        }
    }
}

It seems the boolean values aren’t being reset to their initial values upon death. Have you tried reassigning them in destroyEnemy()?