diff --git a/scene/main/node.cpp b/scene/main/node.cpp index f827f68def0f..67f8a97212ea 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2963,12 +2963,12 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) { } p_node->set_owner(owner); - for (int i = 0; i < owned.size(); i++) { - owned[i]->set_owner(p_node); + for (Node *E : owned) { + E->set_owner(p_node); } - for (int i = 0; i < owned_by_owner.size(); i++) { - owned_by_owner[i]->set_owner(owner); + for (Node *E : owned_by_owner) { + E->set_owner(owner); } p_node->set_scene_file_path(get_scene_file_path());