Call function in another script not working (SOLVED)

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

Hello guys !
I’ve read a lot of threads but still can’t solve my problem.
So i have this

    extends Area2D

const player = preload("res://Player/Player.gd")

func _on_Enemy_area_entered(area):
	var p = player.new()
	p.on_enemy_death(10)
	queue_free()

It’s the enemy i want wen the enemy died, he give 10Xp to the player
here the func in the player:

func on_enemy_death(var expGained):
	XP += expGained

Strangely, nothing happens when the enemy is touched, it only disappears.
I hope someone can save me. If you need more details I can provide them to you.

:bust_in_silhouette: Reply From: Tademame

Just i do
onready var player = get_tree().get_root().find_node("Player", true, false)
and it’s working