Hi, Gdscript doesn't work with reference variables. If you want to modify your player's alive property from the enemy script, you have to store the player node instead of the alive property. So the code would end up something like this:
extends KinematicBody2D
onready var player = get_tree().get_root().get_node("World/Player")
onready var spawn_point = get_tree().get_root().get_node("World/Player").spawn_point
func _ready():
$area_enemy.connect("body_entered", self, "on_area_enemy_entered")
$hitbox.connect("body_entered", self,"on_hitbox_entered")
func on_area_enemy_body_entered(body):
if body.name == "Player":
player.alive = false
body.position = spawn_point
func on_hitbox_entered(body):
if body.name == "Player" and player.alive:
queue_free()
EDIT: Added player.alive condition for hitbox entered and enemy death. If not, the enemy will be removed even though the player was hit first.