It probably has something to do with this line:
if not $AnimationPlayer.is_playing():
$AnimationPlayer.play("metarigAction")
If $AnimationPlayer is null, that could be a problem. You can check for null or use is_instance_valid(). It's also not a good idea to be using $ and get node all over the place. Save the reference at the top and use that (there is a cost to checking the tree).
extends Spatial
onready var anim_player = get_node("AnimationPlayer")
Also, it is a bad idea to name your nodes with the name of the base class, sometimes this causes problems. You can rename the animation node to "PlayerAnim" or something like that. Self is also implied and not needed to refer to your own properties. Please make sure that animation name exists and was not deleted or renamed. Then do:
extends Spatial
onready var player_anim = get_node("PlayerAnim")
func _physics_process(delta):
if is_instance_valid(player_anim):
if not player_anim.is_playing():
player_anim.play("ActionName")
var fvecx = global_transform.basis.z.x
var fvecz = global_transform.basis.z.z
global_transform.origin.x += fvecx * delta * .5
global_transform.origin.z += fvecz * delta * .5