Try replacing lines 1-7 with this:
extends KinematicBody2D
var speed = 200
var move_direction = 1
onready var player = get_parent().get_node("Player")
func _process(delta):
# If the player is to the right, direction is positive, otherwise its negative.
move_direction = 1 if player.position > position else -1
func _physics_process(delta):
if abs(position.x - player.position.x) > speed * delta:
move_and_slide(Vector2(speed * move_direction, 0))
it should work if the script is on the enemy and the player is a sibling.