Custom skinned mesh avatar reverts to T-Pose quickly after death before playing my custom death animation

Exactly as the title says. No matter what I do to try to fix it, directly after death, the model reverts to the original T-Pose quickly before my animation is applied.

Here is what I mean:

Here is the server script that handles the animation:

local char = script.Parent
local hum = char:WaitForChild("Humanoid")

local player = game.Players:GetPlayerFromCharacter(char)

local anims = script:GetChildren()
local randomAnim = anims[math.random(1, #anims)] -- Select a random death animation

local animationTrack -- Variable to hold the animation track
local db = false

-- Preload the animation when the character spawns
local deathAnims = {
	
	randomDeathAnim = hum:WaitForChild("Animator"):LoadAnimation(randomAnim)
	
}

local function deathCheck(health)
	
	if hum.Health <= 0 then
		if db == true then return end
		db = true

		-- Disable the default death state
		hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)

		char:FindFirstChild("HumanoidRootPart").Anchored = true
		char:FindFirstChild("HumanoidRootPart").Position += Vector3.new(0, 0.25, 0)

		-- Stop all animations
		for i, v in pairs(hum:GetPlayingAnimationTracks()) do
			v:Stop()
		end

		-- Play custom death animation
		deathAnims.randomDeathAnim:Play()

	end
	
end

hum.HealthChanged:Connect(deathCheck)

I’ve been trying to fix this for a few hours now and I am completely stumped on what could be causing this, or even how to fix it. All help is greatly appreciated, thank you!

1 Like

I would recommend using the .Died event on a humanoid, and also maybe Play the animation before stopping all the others:

– Stop all animations
– Play custom death animation
deathAnims.randomDeathAnim:Play()
for i, v in pairs(hum:GetPlayingAnimationTracks()) do
if v == deathAnims.randomDeathAnim then continue end
v:Stop()
end

Also no point really disabling default death state since the state had already become Dead

2 Likes

I appreciate the feedback and have revised my script using your feedback, but the problem still occurs with no visual difference. I’m totally stumped. :sweat_smile:

local char = script.Parent
local hum = char:WaitForChild("Humanoid")

local player = game.Players:GetPlayerFromCharacter(char)

local anims = script:GetChildren()
local randomAnim = anims[math.random(1, #anims)] -- Select a random death animation

local animationTrack -- Variable to hold the animation track

-- Preload the animation when the character spawns
local deathAnims = {
	
	randomDeathAnim = hum:WaitForChild("Animator"):LoadAnimation(randomAnim)
	
}

hum.Died:Connect(function()
	
	char:FindFirstChild("HumanoidRootPart").Anchored = true
	char:FindFirstChild("HumanoidRootPart").Position += Vector3.new(0, 0.35, 0)
	
	deathAnims.randomDeathAnim:Play()
	
	-- Stop all animations besides the death animation
	for i, v in pairs(hum:GetPlayingAnimationTracks()) do
		if v == deathAnims.randomDeathAnim then continue end
			
		v:Stop()

	end
	
end)

I assume this is running on the client?

It’s run via a server script, not a local script.

Try run it on the client instead and see if its a latency issue instead, the client has network ownership so running the animations will still replicate.

It works perfectly on the client, but this introduces two issues:

  1. For some reason unbeknownst to me, I simply don’t respawn after dying.
  2. It still has the same T-Pose problem when viewed from the server or another client.

Hmm, try set the Death animation priority to action4, and stop the currently playing animations with a fade out time?

1 Like

The death animations were already priority Action4 and fading out animations with 0.2 fixed the replication to the server and other clients! Thank you!

But I still cannot respawn for some reason. It’s the exact same code in the server script, just put into a local script.

EDIT: I think I see the problem, I’m going to try to handle the anchoring of the HRP on the server.

1 Like

Worked perfectly! Thank you so much for helping me out and walking me through this!

1 Like