Humanoid.Died event stopped working for no reason at all?

Hi there,

I’ve been working on a game for a while now and I wanted the players to turn into ragdolls when they die. I decided to achieve this by putting all functions such as ragdolls, interactions, custom camera, etc, on separate module scripts and running them from one main local script to keep things organized.

Here’s a mock-up script to better illustrate the functionality:

-- this script is in StarterPlayerScripts
local rag = require(game.ReplicatedStorage.ragdoll)

game.Players.LocalPlayer.CharacterAdded:Connect(function(c)
    c:WaitForChild("Humanoid").Died:Connect(rag.makeRagdoll)
end)

This all worked perfectly fine when I first made it (it was about month ago). One of the reasons I opted for this was because the Characters don’t load automatically and need to be spawned with :LoadCharacter() , and I personally found it easier to control all player related things through one script with modules.
However, for apparently no reason, when I tried it out again yesterday, this decided to stop working. I checked both scripts twice, if not thrice, and i came to the conclusion that the .Died event does not fire at all? I am certain I made no changes to either of the scripts because they worked perfectly fine

If anyone has any insight as to why this might happen, as well as a potential fix, I’d be very thankful if you could help me!
Thanks <3

Have you tried executing a print function when it dies?

1 Like

Things I suggest checking out if you have not already:

  1. Making sure the script is running and the CharacterAdded connection is up before LoadCharacter is called.
  2. WaitForChild does time out, so if the character loads slow for any reason it will fail to connect the Died event.

However the above 2 statements are probably not the cause as in theory based on the mockup script you have shown, everything should be loading pretty quickly assuming the game doesn’t have a lot of high performing scripts running during the character loading step.

I would add prints in the Died connection and module to see if those are being reached. If not, it could be an issue with the CharacterAdded (in the event the character already loaded beforehand, then this wouldn’t be fired.)

1 Like

I did, that’s how I came to the conclusion that the event doesn’t work at all

It’s interesting, because everything in the CharacterAdded connection works. The custom camera, footsteps and other modules run normally. But no matter what I tried doing, (printing in the died connection, printing in the module), nothing would get it to work :man_shrugging: which makes no sense because it used to work perfectly fine and now all of a sudden it’s broken? I’ll keep looking into though, thanks either way.

I just ran this in my studio and it worked perfectly fine?

game.Players.LocalPlayer.CharacterAdded:Connect(function(c)
	c:WaitForChild("Humanoid").Died:Connect(function()
		print("test")
	end)
end)

Are you sure your module isn’t the issue?

1 Like

Actually, I just realized the issue is my own fault lmao. It was an oversight; one of the modules had an infinite loop for the interaction, so the humanoid.Died connection wouldn’t even be created in the first place :grimacing: :sweat_smile: sorry, thanks anyway though! should’ve been more careful