Issues - Play Animation when humanoid died

Hello, does anyone know what is wrong?
I want an animation to play when the humanoid’s life reaches 0.

That way: the humanoid does not move from its position and play fall animation

Server Script:

			if humanoid.Health <= 0 then
				print('humanoid HP  is <= 0')
				local fallAnim = humanoid:LoadAnimation(script.fall)
				fallAnim:Play()
				print('Fall Animation has been played')
			end

u cant play it because the humanoid died

Might work:

local fallAnim = humanoid:LoadAnimation(script.fall)
				
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
fallAnim:Play()
			print('Fall Animation has been played')
end)
1 Like

also its if humanoid.Health == 0

Not Exactly, its better to do <= so if the health happens to go into the negatives (This has happened before, not making this up), it will still run.

For Better Context:

== Exactly Equal to
~= Not Equal to
< Less Than
> Greater Than
<= Less Than or Equal to
>= Greater Than or Equal to

yes im saying that its :

If humanoid.Health <= 0 or humanoid.Health == 0 then

There is no point in adding or humanoid.Health == 0, <= is really all you need
Because <= means less than or equal to

true i just like to do that for some reason

replace if humanoid.health with

humanoid.Died:Wait()

oh also change humanoid:LoadAnimation with humanoid.Animator:LoadAnimation()

It works but after the animation is played the humanoid stays stiff with the tool in hand and not in the last position of the played animation, what is wrong with that?

image

You can probably:

fallAnim.Ended:Connect(function()
humanoid.BreakJointsOnDeath = true
end)

I doubt this works but try it

If it doesnt, I believe there is a BreakJoints function

i would rather create a value [server-sided]

then i would do something like:

local Health = Instance.new("NumberValue", player)
Health.Name = "Health"
Health.Value = 100

after that do something like

player.Health:GetPropertyChangedSignal("Value"):Connect()

if player.Health.Value == 0 then
print"Dead, but without ragdoll or stuff"
end

end)
 


don’t used humanoid health, it’s kinda annoying to deal with in many occasions…

with this variable you can change his health to anything you wish without ruining some physics or some weird stuff happening

USE HUMANOID.DIED PEOPLE. IT’S NOT GONNA WORK IF YOU CHECK IF HEALTH IF OVER 0. sorry but i’ve seen people with this issue and .died fixed it.

Already Did that friend :confused:

you did. not sure if the op did. charrrr

I still have the same problem, it plays the animation and immediately freezes in this position and then respawns…

I would like it to play the animation once and stay on the ground (it’s death animation) :frowning:

How can it be solved? I would really appreciate it if you give me a hand :frowning:


local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.BreakJointsOnDeath = false
		local humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
		local fallAnim = humanoid:LoadAnimation(game.StarterPack.Snowball.back_SnowBall.fall)
		humanoid.BreakJointsOnDeath = false
		humanoid.Died:Connect(function()
			fallAnim:Play()
			wait(.5)
			print('Fall Animation has been played')
		end)
		
		fallAnim.Ended:Connect(function()
			humanoid.BreakJointsOnDeath = true
		end)
		
		
	end)
end)

image

Have you tried this

humanoid.BreakJointsOnDeath = false
if humanoid.Health <= 0 then
				print('humanoid HP  is <= 0')
				local fallAnim = humanoid:LoadAnimation(script.fall)
				fallAnim:Play()
				print('Fall Animation has been played')
			end

You can always refrain the character from dying and make sure it plays the animation and then set health < 0 for example.

if player.Humanoid.Health - damage <= 0 then
	--your anim code
	
	
	task.wait(0) -- duration of ur animation
	player.Humanoid.Health -= damage
end

I tried both and the same thing still happens… :frowning: