hurt box connect() func error/

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By iiAnasEG

It gives me these errors:

1- Invalid argument for “connect()” function: argument 2 should be “Callable” but is “HurtBox”.

2- Invalid argument for “connect()” function: argument 3 should be “int” but is “String”.

code:

 class_name HurtBox
 extends Area2D

func _init() -> void:
	monitorable = false
	collision_mask = 2


func _ready() -> void:
	connect("area_entered", self, "_on_area_entered")
	pass


func _on_area_entered(hitbox: HitBox) -> void:
	print("done")
	if owner.has_method("take_damage"):
		owner.take_damage(hitbox.damage)
:bust_in_silhouette: Reply From: JCJL

I believe the syntax you’re using is for godot 3.x and it has changed for godot 4.
Instead of:

connect("area_entered", self, "_on_area_entered")

Try this:


timeout.connect(_on_area_entered)

I believe the documentation on signals is updated to godot 4: