So I'm trying to make a pickup system in godot and the code looks something like this
if Input.is_action_just_pressed("Interact") and object == null:
for index in get_slide_count():
var collision = get_slide_collision(index).collider
if collision.is_in_group("Object"):
object = collision
collision.get_parent().remove_child(collision)
self.add_child(collision)
collision.position = Vector2(0, 0)
But when I equip it the player starts glithching out and starts moving around weirdly.
PLz help