Queue free not working or giving errors

Godot Version

4.2

Question

extends CharacterBody3D

var health = 100

func _ready():
	pass

func _proccess(delta):
	if health <= 0:
		queue_free()

enemy does not appear to take damage but it does detect its being hit and im not sure why im very need to all of this anything helps

Based on only the code you provided, you never modify the health variable of the CharacterBody3D, essentially never triggering your if statement since the value will always be 100. Do you modify the value somewhere else?

Where is your hit function?

i believe it’s just you queue_free() so many times before this node actually being freed, so put a variable to detect if it’s being queue free-ing or not, so it will only be accessed one time

something like

var is_destroying:bool=false
func destroy():
	if is_destroying:
		return
	is_destroying=true
	queue_free()
	is_destroying=false

or simply try to disable the process like:

func _proccess(delta):
	if health <= 0:
		set_process(false)
		queue_free()