I am by no means an expert here. But I am curious why you are using the hide() function for your animations. I don't believe that is necessary.
I'll start by recommending Heartbeasts tutorial here it's fantastic and should give you a good starting point.
As for your script. It looks to be over complicated. But I guess it depends on what you are after. This is a snippet from Ben's tutorial:
const SPEED = 200
var motion = Vector2()
motion.x = SPEED
$Sprite.flip_h = false
motion.x = -SPEED
$Sprite.flip_h = true
motion.x = 0
I'm not entirely sure how you would implement this into your code...but maybe it will help? ¯_(ツ)_/¯