Having Issues Playing an Animation when an NPC Dies

Hello, I am currently working on a Tower Defense game and today I was making animations for the enemies. One of the animations I made was a death animation, which plays when an enemy reaches the end of the track or when they get killed mid way through the track. The problem I am having while trying to play this animation I believe is that the enemy falls over, so it causes the enemy to kind of freak out while the animations plays. If anyone knows a reliable way of keeping the character from falling then that would really help.

Here is a video of what it looks like (Sorry for the poor quality, I can’t record with good quality on my laptop):

There aren’t any solutions I have tried so far because I am unsure of how to keep the enemy unanchored so the animation can play while also stopping them from falling.

1 Like

try making it so that when the character dies, it automatically becomes anchored and plays the animation

Maybe when he dies anchor him before you play the animation?

This, but anchor the humanoidrootpart only???

If I anchor the npc before playing the animation, wouldn’t it prevent the animation from being able to play?

After the animation begins playing unanchor it.

I was thinking the same honestly, but maybe try it first and see what happens?
If that doesn’t work maybe try Instancing a new part below the zombie for him to fall over and not get moved by the conveyor? But that might cause issues if other NPCs collide with that instance.

Alright. Cause I think what causes them to fall over is the fact that I am using Humanoid:MoveTo() to move them to different points on the track so I have to cancel to movement when the humanoid dies. I am thinking that this causes the npc to fall over. I will go try anchoring the HumanoidRootPart and see if that works

Well then, if you are using the MoveTo, make it so when they die the MoveTo stops.

Or :Destroy() their Humanoid so the MoveTo stops

How could I stop the move to when they die? I couldn’t seem to find that when looking at other posts before I made this one, and results I did find didn’t fix my issue. I think the MoveTo is causing the problem as the enemy tries to move when they humanoid can’t because it died so it doesn’t end.
Also I would attempt deleting the humanoid but I need it to load the animation track.

I was trying to make an environement to try and fix your issue but I am very bad at playing animations on NPCs, however, using this:

local humanoid = script.Parent.Humanoid
local pointa = workspace.pointA
local pointb = workspace.pointB

humanoid:MoveTo(pointa.Position)
humanoid.MoveToFinished:Wait()
humanoid:MoveTo(pointb.Position)
-- Add as many points as you please.

I noticed that when the humanoid reaches 0 hp at any point in the script , the dummy just flops to the ground without moving forward anymore. So maybe it’s how you set-upped your animation to play is where the issue lies?

After looking at some other posts about animating without a humanoid, I will see if I can use an AnimationController so that I can try deleting the humanoid like you suggested

That could be the issue. I am firing a Humanoid.Died event in a script in the enemy separate from the main script that moves the enemies. I think as a result it is possible I am playing the animation too late