How can you play an AnimationTrack on humanoid death?

Hello. I’m making a death animation, I loop through all the models in the workspace and then checking if they have a humanoid in them, if they do I play an animaiton which I’ve set, and it’s priority is on action. Also, all humanoids at the beginning are disabled ‘BreakJointsOnDeath’, but it still doesn’t work.
Here’s my code:

local function play_Animation(animationTrack)



local function call_Function()

for _, v in ipairs(workspace:GetChildren()) do
	if v:IsA("Model") then
		if v:FindFirstChild("Humanoid") then
			local humanoid = v:FindFirstChild("Humanoid")
			repeat wait()
			until humanoid.Died:Wait()
			local animation = script.DeathAnimation
			local animationTrack = humanoid:LoadAnimation(animation)


while wait() do



Edit: I found a solution already.

I’m not the best at scripting, so to check for mistakes, I’d put some prints in the code. You might want to print something after writing the FindFirstChild function to be sure that the humanoid was found.

Edit: Okay, so I did some digging and found that the problem is that your humanoid is actually dying too quickly. If you write

    HumanoidRootPart.Anchored = true

The script might work

Hello. Thank you for answering, but I already found a solution for this problem. Thank you for trying to help still! :slight_smile:

Note: I already found a solution!