_on_area_exited() not working?

Godot Version

4.5.1 stable

Question

Most of this code works except the exiting part. I have no idea why. I’m a godot beginner please be nice >/////<

extends Area3D
@onready var parent = get_parent()


func _process(delta: float) -> void:
	area_entered.connect(_on_area_entered)
func _on_area_entered(area: Area3D):
	parent.inport = true
func _on_area_exited(area: Area3D):
	parent.inport = false

Nevermind, I figured it out

I know you said you figured it out but just making sure since you didn’t actually post the solution and others might be reading this thread;

You connect the signal “area_entered” to _on_area_entered(), but you forgot to connect “area_exited” to _on_area_exited().

Also, code inside _process() runs every frame. This means you’re connecting area_entered every frame. You only need to connect it once, when the node is instantiated. Your code will throw an error every frame and spam your output log with:
ERROR: Signal 'area_entered' is already connected to given callable 'Area3D(YourArea)::_on_area_entered' in that object.

Connect your signals inside of _ready() instead

extends Area3D
@onready var parent = get_parent()

func _ready() -> void:
	area_entered.connect(_on_area_entered)
	area_exited.connect(_on_area_exited)

func _on_area_entered(area: Area3D):
	parent.inport = true
func _on_area_exited(area: Area3D):
	parent.inport = false