That error usually means the node in your loop has no 'anim' variable, so either that child does not have the weapon script attached, or the script failed to parse and loaded without its variables. Check the Errors tab and the weapon scene for a red script warning first. Then print w.name and w.get_script() inside the loop in _ready to see which child breaks. It also helps to give the weapon script a class_name and check 'if w is Weapon' before touching w.anim.