How to know wich group am i colliding with when using Raycast 2D?

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

im using this code:

func _process(delta):
var collider = get_collider()

if self.is_colliding():
	get_parent().can_talk = true
	if collider.is_in_group("npc"):
		print ("colliding with npc")

when im about to collide with the object, it gives me this error:

“Attempt to call function ‘is_in_group’ in base ‘null instance’ on a null instance.”