How to Pinjoint2D darts(Kinematicbody2D) on moving wall(StaticBody2D) via gdscript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pengyou

I have a shooting darts (KinematicBody2D) that will stick on a moving wall (staticbody2D).
I wants to let the dart stick on the wall, which is moving over time by changing position.x.
However, the dart does not follow fully the moving path of the wall.

I end up adding pinJoint2D, but setting the node via gdscript only give me an error

Invalid set index 'node_b' (on base: 'PinJoint2D') with value of type 'StaticBody2D (StaticBody2DWall.gd)'.

My code in dart node for setting up pinjoint2d goes as below:

var slide_count = get_slide_count()
if slide_count:
	var collision = get_slide_collision(slide_count - 1)
	var collider = collision.collider
	lif collider.is_in_group("wall"):
		$PinJoint2D.node_b = collider

Anyone please help. Please let me know if there’s a better practice.