How to properly change a child-parent relationship?

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

So currently i trying to make a top down shoote. To be exactly a simple inventory system. So i have a player with a “Hand” and when player gets into Area2D of a gun i try to put “Gun” into “Hand”. But i can’t and don’t have a clue why. I previously make this in Unity but Godot just spits into me with an error wich have no sence to me.
Here’s example of my code:

func _on_HandZone_area_entered(area):
if area.get_parent().is_in_group(“gun”):
area.get_parent().get_parent().remove_child(area.get_parent())
$Hand.add_child(area.get_parent())

This is what i want to do:
Scene Tree

from this:
Main Scene

Would you also share the error that it’s giving you?

PrecisionRender | 2023-01-30 23:21