Hi, i don't understand your question. The function which recieves the signal can be in any script attached to a node. But when you make the connection, the syntax is <Singal emmiter>.connect("signal name", <signal reciever>, "function to connect to")
In your case, you are trying to connect a signal being emited on an AnimationPlayer2D, to a function on a KinematicBody2D, and you are doing the connection in the KinematicBody2D script. So instead of:
connect("animation_finished",self,"_on_AnimationPlayer_animation_finished")
You should do
$AnimationPlayer.connect("animation_finished",self,"_on_AnimationPlayer_animation_finished")
(I'm assuming your animation player node is direct child of your kinematic, and is called AnimationPlayer here)
So, whenever an animation finished, AnimationPlayer
node will emit automatically the signal animation_finished
and if its correctly connected to your function, then the function will get executed.
The code you gave, uses connect
directly on an script that extends KinematicBody2D, but that node does not have those signals.
If you connected the animation player's signal from the editor in the node tab, then you shouldnt need those connect instructions.