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
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.