Animation States not working, can someone help me please?

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

I’m trying to make my enemy die animation run when it collides with a certain area of my player and the function is called however it states that I have an invalid call to nonexistent function ‘travel’ in base nil, here is my code for the player:

extends KinematicBody2D

var state_machine

const UP = Vector2(0,-1)
const GRAVITY = 20
const ACCELERATION = 50
const MAX_SPEED = 200
const JUMP_HEIGHT = -550

var motion = Vector2()
var enemy

func _ready():
    state_machine = $PlayerAnimationTree.get("parameters/playback")
    state_machine.start("Idle")
    enemy = preload("res://Prefabs/Snake_Enemy.gd").new()
func _physics_process(delta):
    motion.y += GRAVITY
    var friction = false

if Input.is_action_pressed("ui_right"):
	motion.x = min(motion.x + ACCELERATION, MAX_SPEED)
	state_machine.travel("Walking")
	$Sprite.scale.x = -0.1
	get_node("ColLeft").set_disabled(false)
	get_node("ColRight").set_disabled(true)
elif Input.is_action_pressed("ui_left"):
	motion.x = max(motion.x - ACCELERATION, -MAX_SPEED)
	state_machine.travel("Walking")
	$Sprite.scale.x = 0.1
	get_node("ColLeft").set_disabled(true)
	get_node("ColRight").set_disabled(false)
elif Input.is_action_just_pressed("ui_accept"):
	state_machine.travel("Attack")
	
else:
	friction = true 
	state_machine.travel("Idle")
	
if is_on_floor():
	if Input.is_action_just_pressed("ui_up"):
		motion.y = JUMP_HEIGHT
	if friction == true:
		motion.x = lerp(motion.x, 0, 0.2)

			
else:
	if motion.y > 0:
		state_machine.travel("Jump")
	if motion.y < -50:
		state_machine.travel("Fall")

	else:
		state_machine.travel("Fall")
	
	if friction == true:
		motion.x = lerp(motion.x, 0, 0.05)

motion = move_and_slide(motion, UP)
pass


func attack():
    state_machine.travel("Attack")
func die():
    state_machine.travel("Die")

func _on_TongueHit_area_entered(area):
if  area.get_name() == "HurtBox":
	enemy.Dead()
	area.get_parent().call_deferred("queue_free")
	print("Enemy Die") 

Here is the code for the enemy

extends KinematicBody2D

# CONSTANT VARIABLES 
const GRAVITY = 20
const SPEED = 200
const FLOOR = Vector2(0, -1)


# VARIABLES 
var velocity = Vector2()
var direction = 1
var state_machine
var is_dead = false

# FUNCTIONS 
func _ready():
state_machine = $AnimationTree.get("parameters/playback")
state_machine.start("Idle")

func _physics_process(delta):
if is_dead == false:
	velocity.x = SPEED * -direction
	
	if direction == -1:
		$Walk.scale.x = -0.1
		
	else:
		$Walk.scale.x = 0.1	
	Walk()
	velocity.y += GRAVITY
	
	velocity = move_and_slide(velocity, FLOOR)
	
	if is_on_wall():
		direction = direction * -1
		$RayCast2D.position.x *= -1
		
	if $RayCast2D.is_colliding() == false:
		direction = direction * -1
		$RayCast2D.position.x *= -1

func Dead():
state_machine.travel("Die")		
    is_dead = true
    velocity = Vector2(0,0)
    print("DIE")
func Walk():
    state_machine.travel("Walk") 
func Idle():
    state_machine.trave("Idle")
func Attack():
    state_machine.travel("Attack")