Can you give this a try?
func clone(node: Node) -> Node:
var copy = node.duplicate()
# see https://docs.godotengine.org/en/3.1/classes/class_object.html#id2
var properties: Array = node.get_property_list()
var script_properties: Array = 
for prop in properties:
# see https://docs.godotengine.org/en/3.1/classes/[email protected]#enum-globalscope-propertyusageflags
# basically here we are getting any of the user-defined script variables that exist, since those apparently don't
# get copied via `duplicate()`
if prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE == PROPERTY_USAGE_SCRIPT_VARIABLE:
for prop in script_properties:
I would suggest putting that in an autoloaded script (
Utils.gd or something) so that you can call it from anywhere like:
var friend_node = Utils.clone(lonely_node)
Apparently this is not what you were asking. If you just want to be able to duplicate a node in the editor, save the node you want to duplicate as its own scene. Then go to the scene you want it to be in, right-click the root node, select "Instance Child Scene", and select the node/scene you want.