How do I copy a node and change its parent?

Godot Version

v4.1.2.stable.official [399c9dc39]


I’m new to Godot, and I can’t figure out how to copy a node and change it’s parent. I have this code, which isn’t producing any errors, but when I run it nothing physically changes in the scene

extends Node2D

var canPlaceNew = true

var ButtonLayer
var CopyImage

func _input(event):
	if event.is_action_pressed("NewImage") and canPlaceNew == true:
		var CopyImage = get_tree().get_first_node_in_group("CopyImage")
		var ButtonLayer = get_tree().get_first_node_in_group("ButtonLayer")
		print("I Placed A New Image Look At Me Go")
		var DirtyPlagarist = CopyImage.duplicate(true) = "SuchAPlagarist"
		var new_parent = ButtonLayer
		DirtyPlagarist.position = Vector2(374, 423)

CopyImage is the node I am copying and ButtonLayer is the UI layer. I am using groups to get the nodes because the script is an autoload and I can’t find another way to get the nodes. I can provide more information if this isn’t enough. If the solution to this problem is obvious, please write your answer in comic sans so that I know I’m an idiot. Thank you.

something like this

@onready var the_node_you_want_to_copy=$"FirstParent/TheNode"
@onready var new_parent_node=$SecondParent

func copy_and_move():
	var copied_node=the_node_you_want_to_copy.duplicate()