Help with making enemy disappear when attacked

For Godot 4

Hello everyone. I was wondering if someone could help explain the process of getting an enemy to disappear after they have been attacked. I have watched 2 different tutorials and I am having trouble connecting the dots on how to convert what they have said into a way I can understand it. I currently have a hitbox set up to where it is suppose to KO anything that is within the area but it is not working.

Here is my code:

extends CharacterBody2D

#This class_name will make it so that it can be called/used in other areas
class_name Player

#Will send a signal whenever the health needs to be updated
signal health_updated(health)
#will send a signal when the player runs out of health
signal hit

#This will check to see if our player is dying
var is_dying = false
#This will check to see if our player is attacking
var is_attacking = false

#This line will make a “speed” box appear under “” on the right side that can be editted.
@export var speed : float = 200.0
@export var jump_velocity : float = -80.0
@export var double_jump_velocity : float = -100
@export var attacking = false
@onready var animated_sprite : AnimatedSprite2D = $AnimatedSprite2D
@onready var death_timer = $death_timer

#Gets the gravity from the project settings to be synced with Rigidbody nodes.
var gravity = ProjectSettings.get_setting(“physics/2d/default_gravity”)
var has_double_jumped : bool = false
var animation_locked : bool = false
var direction : Vector2 = Vector2.ZERO
var was_in_air : bool = false

func _ready():
death_timer.connect(“timeout”, Callable(self, “_on_DeathTimer_timeout”))

func _process(delta):
if Input.is_action_just_pressed(“attack”):

func _physics_process(delta):

#Adds the gravity.
if not is_on_floor():
velocity.y += gravity * delta
was_in_air = true
has_double_jumped = false

  if was_in_air == true:
  was_in_air = false

#Handle for jump
if Input.is_action_just_pressed(“jump”):
if is_on_floor():
#Normal jump from the floor
elif not has_double_jumped:
#double jump in the air

#Gets the input direction and handles the movement/declaration.
#As good practice replace UI actions with custom gameplay actions.
direction = Input.get_vector(“left”, “right”, “up”, “down”)

if direction.x != 0 && animated_sprite.animation != “jump_end”:
velocity.x = direction.x * speed
velocity.x = move_toward(velocity.x, 0, speed)


func update_animation():
if not animation_locked:
if not is_on_floor():“jump_fall”)
if direction.x != 0:“walk”)

func update_facing_direction():
if direction.x > 0:
animated_sprite.flip_h = false
elif direction.x < 0:
animated_sprite.flip_h = true

func attack():
print(“Is attacking”)

This will check for anything inside of the hitbox and will put it into a list

var overlapping_objects = $Punch_hitbox.get_overlapping_areas()

for area in overlapping_objects:
var parent = area.get_parent()

attacking = true“attack”)
animation_locked = true

func jump():
velocity.y = jump_velocity“jump_start”)
animation_locked = true

func double_jump():
velocity.y = double_jump_velocity“jump_double”)
animation_locked = true
has_double_jumped = true

func land():“jump_end”)
animation_locked = true

func _on_animated_sprite_2d_animation_finished():
if([“jump_end”, “jump_start”, “jump_double”, “attack”].has(animated_sprite.animation)):
animation_locked = false

func _on_punch_hitbox_area_entered(area):
if area.get_name() == “Punch_hitbox”: