As i see in your code above the variable animation_has_played
will NEVER work as you expect because since u go back to the scene u (RE)LOAD this scene again, and the scripts says every single time the scene is loaded:
var animation_has_played = false
Using singletons is the right way. Create a new script without attaching it to any node. Name it like Global.gd (example) and move this var into Global.gd
var animation_has_played = false
go Project settings - autoload and add this script there. Then set global var to TRUE after animation has played. U can do it in the script of the scene\level. Like this:
Global.animation_has_played = true
and of course the first line of your _ready() fn in the scene with animation must be
func _ready( ):
if not Global.animation_has_played:
#do smth
and just for sure, untick "autoplay animation" in animationplayer.