How do i make kills not register if dead body is shot?

hello developer people!

i made a simple kill check that register a kill to a player stat if target humanoid health is 0 but it got issues
if killer shoots dead body 5 times of a player he killed, 6 kills would register to killer
also if any other player shoots a dead body, the kill would also register to them, even if they didnt do anything to the victim

this is the damage/kill detection part of the framework (local script)

		if part then
			if part.Parent:FindFirstChild("Humanoid") then
				if part.Name == "Head" then
					damage = WeaponData.HeadDamage
					if part.Parent.Humanoid.Health - damage <= 0 then
						plr.PlayerScripts.KOValue.Value += 1	
				else
					damage = WeaponData.Damage
					if part.Parent.Humanoid.Health - damage <= 0 then
						plr.PlayerScripts.KOValue.Value += 1
					end
				end
			end
		end

any ideas are appreciated !

1 Like

Before dealing the damage/adding to any values, make sure that the humanoids health isnt already zero.
Alternatively, you create a boolValue inside of the corpse, and check if its there before adding to any values.

3 Likes

You could also check if the humanoid’s state is ‘Died’ or if the humanoid contains a set attribute.
Humanoid:SetAttribute("Died", true)

1 Like