Humanoid.Died not firing/ delayed

I wrote a script that makes the character play an animation upon death, however the humanoid.Died state sometimes does not fire or fire a few seconds after humanoid is at 0 health. I have tried using humanoid.HealthChanged instead but it also did not fire. Here is my script:

humanoid.Died:Connect(function()
	Track:Play()
	Track.Stopped:Connect(function()
		ragdoll() --ragdoll script worked, most likely not the cause
	end)
end)

I’m expecting the “died” event to fire the moment the humanoid’s health is depleted.

In addition: if the player zooms into 1st person and looks around while the humanoid’s health is 0 the “died” event will magically fire.

1 Like

are you using local script or server script? I had similar issue when using server script

I put everything related to the ragdoll is written in the server script.

make it local script it will replicate to server anyway

Just to be sure: the lagging is on the “died” event not on the animation if that is what you are referring to

I need to trigger the ragdoll (which is on server) once the track has ended - how would I be able to do that (other than using remote events);

Try listening for the event on client then fire a RemoteEvent? Or listen with .HealthChanged?

1 Like

I am trying to avoid the use of RemoteEvents because I can’t think of an effective way to prevent hackers to exploit it [the remote events] and ragdoll random people

just make it on client it will replicate anyway

may you show a gif of the script firing so we can identify the exact issue clearer

Or using .HealthChanged. Or GetPropertyChangedSignal

Better to use HealthChanged since it passes the humanoid’s new health to the connected callback function(s).

local function OnHealthChanged(Health)
	--'Health' is a reference to the humanoid's health.
end

Humanoid.HealthChanged:Connect(OnHealthChanged)

I have already tried this method and have stated the results above

Currently the only effective way I found to achieve my objective was to listen on the client side and replicate it to the server using remote events (also this topic is solved thx for trying to help)

2 Likes