Humanoid.Died won't fire!

I’m making a round-based game and I have a function that listens when a humanoid dies. It’s just that .Died won’t fire. Here’s my code:

local function ListenForDeath(t: table?, signal: Signal?, maid: Maid?)
	for _, player in ipairs(t) do
		local character = player.Character
		local humanoid = character and character:FindFirstChildOfClass("Humanoid")
		if not humanoid or (humanoid and humanoid.Health < 1) then
			Signal:Fire()
			continue
		end
		maid[humanoid] = humanoid.Died:Connect(function()
			signal:Fire(player)
			maid[humanoid] = nil
		end)
	end
end

Thanks for any help! :heart:

It’s probably because of this line. Try changing it to

local humanoid = character:FindFirstChildOfClass("Humanoid")
2 Likes

I can confirm it’s not that line because when I do Humanoid:GetFullName(), it prints workspace.ChainsawRBLX.Humanoid. I’ll still try it though.

Edit: It doesn’t seem to work.

Is humanoid.Died just not firing at all or is there a problem with the bindable event? Have you tried adding a print to check?

When do you call the function. When the player joins?

Yeah, I tried adding prints. It doesn’t print anything inside the code block.

I call the function when the round starts. Like this:

local new_signal = Signal.new()
local maid = self._maid

ListenForDeath(players, new_signal, maid)

One last thing you could try is simplifying this code, events automatically disconnect when an instance is destroyed. If the player dies, their humanoid is destroyed when they respawn.

humanoid.Died:Connect(function()
			signal:Fire(player)
end)

I’ll try that right now, thanks for helping. :smiley:

Oh my god… It works!
You don’t know how big of a problem you have solved for me. Thank you so much! :heart:

1 Like