So I have a serverside hit registration and damage function. They are separate because a hit can be dodged, with a certain chance. If the damage function is called, there are some references passed through, such as the humanoid to be damaged, the CFrame of the hit position, damage amount, etc.
I have no problem applying the damage, but I have a problem detecting singular kills of any humanoids. If I simply detect if the humanoid's health is 0 then call a separate function that could get messy and my game has a feature where time can be stopped and hundreds of hits can be stacked until it is resumed, and all the hits register at once. This is where my problem comes in. With this solution, normal kills are fine because hits to humanoids with 0 health are usually filtered out, but if the time is stopped at a time where the humanoid's health > 0 then the damage is added to the stack, as it has no way of knowing the previous hit would've killed it.
This is my problem. How should I detect this humanoid's death without using any ObjectValues to point to a damage dealer or anything like that?
here
PLAYERNAME.Character.Humanoid.Died:Connect(function() -- code here end)
if you want it for every player then...
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) repeat wait() until char:FindFirstChild"Humanoid" char.Humanoid.Died:Connect(function() --code here end) end) end)
and if you want it for every object in workspace....
for i,v in pairs(workspace:GetChildren()) do for i,l in pairs(v:GetChildren()) do if l ~= nil and not l:IsA("Humanoid")then for i,x in pairs(v:GetChildren()) do if l ~= nil and not l:IsA("Humanoid")then -- repeat same but changing x to a value that has not been set end else if l:IsA("Humanoid") then l.Died:Connect(function() --code here! end) end else if l:IsA("Humanoid") then l.Died:Connect(function() --code here! end) end end end end
well , there!