What is the problem? Looking at the code and the title of topic, I'm not quite sure where the issue is.
The only thing I can see that might be causing an issue is the use of the local position when calculating the direction. Using the local position works if the parent node is at origin (0, 0), but will have issues if the parent node is offset in any way. To fix this, you just need to use velocity = global_position.direction_to(target) * speed
instead.