How do I make it so I only damage the enemy once?

I recently made a pretty simple FPS game, where you shoot bullets (which are gameObjects) at enemies. I made it so that each Bullet does 5 damage, and that the Enemy has 50 health. So it should take 10 bullets to kill the enemy, but that’s not the case. It only takes one bullet to kill the enemy. I’m assuming its because each bullet is dealing damage multiple times rapidly before it disappears, causing the enemy to die from one bullet.

So what I want to ask is, how do I make it so each bullet is only capable of damaging the enemy once?

Here is my code.

Bullet Code:

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

public class PistolBullet : MonoBehaviour
{

    public float life = 3;

    void Awake()
    {
        Destroy(gameObject, life);
    }

    

    void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.tag == "Enemy")
        {
            collision.gameObject.GetComponent<Enemy>().TakeDamage(5);
          
        }

        Destroy(gameObject);
    }
}

Enemy Code:

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

public class Enemy : MonoBehaviour
{
    public float health = 50f;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void TakeDamage(int damageAmount)
    {
        health -= damageAmount;
        Die();
    }

    void Die()
    {
        Destroy(gameObject);
    }
}

,I have a problem with my damage scripts. Basically, I made a simple shooting game, where each bullet fired is a game object. I set it so that each of those bullets do 5 damage, and the enemy has 50 health, so it should take 10 bullets to kill the enemy. The problem is, it only takes 1 bullet to kill the enemy, and I believe it’s probably because the damage function is being called multiple times, causing the enemy to take damage rapidly.

What I want to ask is, how do I make it so that each bullet deals damage only once?

Here is my bullet script:

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

public class PistolBullet : MonoBehaviour
{
    public float damage = 10f;
    public float life = 3;

    void Awake()
    {
        Destroy(gameObject, life);
    }

    void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.tag == "Enemy")
        {
            collision.gameObject.GetComponent<Enemy>().TakeDamage(5);
          
        }

        Destroy(gameObject);
    }
}

Here is my enemy Script

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

public class Enemy : MonoBehaviour
{
    public float health = 50f;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void TakeDamage(int damageAmount)
    {
        health -= damageAmount;
        Die();
    }

    void Die()
    {
        Destroy(gameObject);
    }
}

Hey.

You’re literally calling Die() whenever the enemy takes damage!
Correct me if I’m wrong, but that’s why this is happening!

Fix it by adding a simple if() statement which checks if the current enemy health is less than or equal to 0. THEN call Die()

Thanks, that seemed to be the problem