Duplicate not working

`Version 4.0

Im having trouble with duplicates. I try to make it so when you click the button a zombie appears on the “placer” tile. but it doesnt show the zombie, but when i print the positions it shows me that they are the same.

Are you adding the duplicate to the scene tree with add_child? You can see the runtime scene tree if you switch to the “Remote” tab in the hierarchy

Without seeing any code we can’t give any specific advice, this is just a guess

1 Like

this is the code:
extends Button
func _on_pressed():
if Global.turn <2:
if Global.brains > 24:
Global.brains = Global.brains - 25
$“../browncoat”.duplicate()
var browncoat = $“../browncoat”.duplicate()
add_child(browncoat)
browncoat.position = $“../Placer”.position

		print(browncoat.position)
		print($"../Placer".position)`

Try using global_position instead if the button node is a UI-node.

browncoat.position = $“../Placer”.global_position

I fixed it the problem was that it was a character2d node and i just had to change it to an Area 2d node

If you’re going to mark a reply as the solution, it should tell people how you fixed it. So that people having similar issues can know how to solve the problem. If @yesko or @baba gave you the solution, you should be marking their reply as the solution. If it was something else, it would help if you explained how it was fixed.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.