Why Do I get Object#Null every time I call a node function

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

Hello, I’m Willi Goen Unity3d Ex-user and I’m trying to learn the Godot engine nowadays to create some small games.
The thing is, I’m currently trying to understand how the engine manages the connection between scenes and scripts because I want to use crossReference between Scenes, and how to call functions and object embed functions.
Now I’m trying to play a simple animation which is loaded on the 3d model, a very basic 3d Chest made in Blender and exported with all of its animations as GlTF 2.0
I’ve followed some tutorials that explain how to do it properly, but the issue comes when I try to execute/play the animations.
I don’t know why I always get the

The code can look like this:

extends Node3D

var hintCalled = false

@export var chest_has_key_lock : bool = false

@onready var area3dRef : Area3D = $Area3D
@onready var chestTop : MeshInstance3D = $ChestTop
@onready var chestBottom :  MeshInstance3D = $ChestBottom
@onready var _animPlayer : AnimationPlayer = $AnimationPlayer

var player_in_front : bool = false
var is_chest_opened : bool = false

func _ready() -> void: 
     #To know if the assets are being loaded correctly
	_animPlayer = get_node("AnimationPlayer")
	print(str(_animPlayer))
	pass # Replace with function body.

func _process(delta):
	if  player_in_front:
		# if the chest doesn't have any keylock then player can open it
		if Input.is_action_just_pressed("action"):
			if chest_has_key_lock == false:
				if _animPlayer != null:
					OpenChest()

/#else if the chest does have a key lock, then player needs to have the key
		else:
			if hintCalled == false:
				print("needs key")
				hintCalled = true
			#Get key from player!
	pass
func OpenChest():
	print("Chest opened")
	_animPlayer.play("Open")

func _on_body_entered(body):
	if body.name == "Player":
		player_in_front = true
		print("Entered the area" + " " + "player_in_front= " + str(player_in_front))

func _on_body_exited(body):
	if body.name == "Player":
		player_in_front = false
		print("Exited the area" + " " + "player_in_front= " + str(player_in_front))
		hintCalled = false


Sorry for the mess up, I only have 2 days of flight on Godot

:bust_in_silhouette: Reply From: willi

Well, I think that I’ve found the issue. I’ve attached the script on a child of the parent who was calling all of the actions… As a result, an error occurred because of the duplicity of the calls.
Hoping that It solves all of my headaches, Sorry for the miss understanding, I’m having trouble getting myself comfortable with the one script per asset that Godot uses.