Humanoid.Died doesn't trigger in certain situations

In my game, Humanoid.Died is only triggering when the player dies due to resetting & NOT when the player dies due to Humanoid:TakeDamage (which comes from the pvp aspect in my game).

Here is a video showing the issue:

Here is the code that detects the humanoid death:
image

Here is the line that deals the damage during pvp:
image

To try & come to a solution, instead of using :TakeDamage(), I tried to just directly set the Humanoid’s Health & Clamp it so that it wouldn’t dip below 0 (because the documentation for the Died event states that This event fires when the Humanoid dies, usually when Humanoid.Health reaches 0." but it seemingly changed nothing in terms of my problem.

1 Like

Are you damaging players via local script? Humanoid.Died detects TakeDamage while both are used on server scripts.

1 Like

:TakeDamage() is on the server, but Humanoid.Died is on the client.

I feel like your claim here isn’t true because using :TakeDamage() on the server still changes the Humanoid’s Health and kills the Humanoid, as seen in the video.

But even if your claim was correct, in my post, I mention that I tried replacing :TakeDamage() with directly setting the HP of the Humanoid, but that also didn’t work.

1 Like

I just tested it myself, using both Humanoid:TakeDamage() and setting health directly to 0 (on server script) both works and sets off a detection event on a local script, so it is something else wrong.

1 Like

Yeah it was something else…

I have some code in my game that drops all tools in a player’s possession when they die.

Long story short: The Humanoid.Died event code wasn’t running because the LocalScript that it was inside of was put into the Workspace (where LocalScripts can’t execute in) before Humanoid.Died could detect that the humanoid had died.

I just did some code rearranging to make sure that the Humanoid.Died event was triggered before the tool was dropped upon death & now things work as intended

Using Run Context may be a better solution in the future to allow LocalScripts to more freely run code in any part of a game.

2 Likes

Even then, it doesn’t explain in my original problem how dying due to resetting allowed Hunanoid.Died to trigger, but dying due to Humanoid:TakeDamage() didn’t trigger it…

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.