onready var raycast = get_node("RayCast")
var held_item
if event.isactionpressed("interact") and iteminrange:
helditem = raycast.getcollider()
var instance = helditem.instance()
helditem.queuefree()
hand.addchild(instance)
This is my code. "Invalid call. Nonexistent function 'instance' in base 'StaticBody (Pot.gd)." is the error it gives. "iteminrange" becomes true when raycast collides with an object(I tested this with print method it works fine). I want to destroy the object I'm looking at and create an instance of it in my hand. What is the problem with this code and is there a better way of doing this. I've been using godot for a fair bit of time but this is my first time looking into 3d so I don't get most diffrences and try to do things in same way I did in 2d so I'm sure this isn't the most efficient code.