Attempt to index nil with 'Play' - Animation error


I’m trying to play an animation when the dummy dies, but, whenever I want to play it, it just sends an error “attempt to index nil with ‘Play’” although the animation got loaded properly.
Is there by any chance a solution to this?
This script is a server script in the Dummy’s model

	if script.Parent.Humanoid.Health <= 1 then
		script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
		local anim = script.Parent.HumanoidRootPart.exploding
		local animplay script.Parent.Humanoid:LoadAnimation(anim)

Thanks in advance.

First of all, you forgot an = sign after the animplay variable, which basically is creating the variable and also Loading the animation, but not assigning it to animplay.

1 Like

I have no idea whether I should be embarrassed or blame my keyboard for not responding correctly…
Thanks a lot!

1 Like

One thing to note that humanoid:LoadAnimation() is now deprecated. Use Animator instead, which is a child of humanoid. This only happens on players, on NPCs they don’t have this instance.


Will keep that noted. Thanks for telling me about that