What this error mean?

Godot Version

4.3
what this error mean? what did i do wrong?
2025-01-25_13-26-29
thank you for attetion

It means that the object is null in which you are calling is_in_group. Maybe its deleted from the scene. Can you provide more details?

1 Like

You can test the object by calling the global function is_instance_valid(object) before using it.

2 Likes
	for target in target_list:
		for target_name in targets:
			if target.is_in_group(target_name) and is_instance_valid(target):

I’m creating a tower defense and I have a tower that when it is touched by the enemy then called function “explode” is my current code to determine whether the enemy has entered the area or not. this part of the code determines which objects will take damage in the explosion area when “explode” is triggered

thank you for you attetion

1 Like

thank you for your attetion

I suggest you switch the order of these conditions, so is_instance_valid is evaluated first:

if is_instance_valid(target) and target.is_in_group(target_name):

The reason is that Godot uses short-circuit evaluation, so if is_instance_valid returns false, it won’t crash on the second condition is_in_group.

1 Like

I tested for a while and no errors occurred. thank you for helping me with my error