Sounds like you're not getting the right object. Or rather: any object. Make sure, the node path is correct, e.g. if you have a scene consisting of a parent node (where the script is attached) and it's child of type AnimationPlayer called "A", your script should include:
get_node("A").play("fade_out")