I need help with my script, Animation not playing on death

image
I have this script that is supposed to play my animation on death but it doesn’t seem to be working, Any advice?

local character = script.Parent
local hrp = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local animation = script:WaitForChild("DeathAnim")
local track = humanoid:LoadAnimation(animation)

local function onDied()
	hrp.Anchored = true
	track:Play()
	track.Stopped:Wait()
	hrp.Anchored = false
end

humanoid.Died:Connect(onDied)

The .Died event of a humanoid instance is fired whenever that humanoid dies (as a result of its health reaching 0). Additionally, the script is destroyed by virtue of it being cloned into the character model of the dead humanoid so script:Destroy() isn’t necessary.