how to delete all nodes of a group?

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

I have several nodes in a group and I want to delete them by code only those that are within that group, i know how delete childrens with:

 for i in get_children():

How do I do them for the nodes that belong to the group?

:bust_in_silhouette: Reply From: felaugmar

You can check if the node is inside the group with this method: Node.is_in_group

:bust_in_silhouette: Reply From: jgodfrey

You could do something like:

for node in get_tree().get_nodes_in_group("enemies"):
	// do something with this enemy node