Why is this code not working to pick up objects

Godot Version

godot 4

Question

I’m working on a script for the player in my game to pick up items.
currently this is what I have so far:

func _pickUp():
	if Ray.is_colliding():
		var obj = Ray.get_collider();
		if (obj.is_in_group("ItemPickups")):
			Item = obj
			add_child(Item)
			Item.freeze = true

this function is called then the player hits a key. for some reason this does… literaly nothing. in theory it checks the raycast collider and if it’s in the item pickup group it parents it to the object this script is on but right now it just kinda… sits there? why doesn’t this work

this seems to have mostly fixed it:

func _pickUp():
	if Ray.is_colliding():
		var obj = Ray.get_collider();
		if (obj.is_in_group("ItemPickups")):
			Item = obj
			Item.reparent(self, true)
			Item.global_position = global_position
			Item.global_rotation = global_rotation
			Item.freeze = true

It’s deffinitely not the perfect solution, but it does what it needs to