I need help with exporting animation player

Godot Version

Godot 4

Question

I’m trying to make an animation of the player play in the main scene when he enters an area, the animation is the player scene and I tried to export it so I can use it in the main scene script, every time I use the .play() function it says that it doesn’t exist and I don’t know why.


that is the main scene script
and for the player scene the variable i have is @onready var anim = %AnimationPlayer

it’s better to just use signal to tell the player to do the player animation of “DoorAnim”, rather like this

or if you insist of doing it like this way
erase the

var animation=player.anim
animation.play("DoorAnim")

replace with:

player.play_animation("DoorAnim")

then in the player script
add a method that takes parameter of string

func play_animation(string_anim):
	anim.play(string_anim)

if this way still say the anim doesnt exist, then something is wrong with how you path/name the animationplayer

Nothing happened yeah but how do I use signal to tell the player to do the animation

use Global EventBus