Humanoid Tagging Not Working

I am trying to implement ROBLOX’s ‘humanoid tagging’ into my game.

My problem here is that, when the humanoid is tagged, I check when it dies and have it print “died” upon so. For some reason, it prints 7 times, even though it died one time and there is only one tag.

Here is some server code:

if HitPart.Name == "Head" then
			UntagHumanoid(HitHumanoid)
			TagHumanoid(HitHumanoid)
			
			Damge = FoundModule.HeadDamage
		else
			UntagHumanoid(HitHumanoid)
			TagHumanoid(HitHumanoid)
			
			Damge = FoundModule.Damage
		end
		
		--//
		if Globals.UseDamageDropOff then
			local PercentDamage = math.clamp(165/Distance, 0, 1)
			FinalDamge = math.round(PercentDamage * Damge)
		else
			FinalDamge = Damge
		end
		
		HitHumanoid:TakeDamage(FinalDamge) -- delete this line bruv
		
		if Enemy and Player then
			
			if Enemy.Team ~= Player.Team then
				
				HitHumanoid:TakeDamage(FinalDamge)
				
			end
			
		end
		
		HitHumanoid.Died:Connect(function()
			local Tag = HitHumanoid:FindFirstChild("creator")
			if Tag then
				print('died')
			end
		end)

and here is whats coming out of the console.

image

from what im aware of, no one else has had this issue.

And your sure it’s not been hit 7 times, thus connecting 7 prints to the death?

Maybe add a debounce? Idk if it would help.

Every time the humanoid is hit, i just check in a .Died event so i dont know

It looks like you make the script listen for the humanoid’s death every time it gets hit. Those listeners don’t time out, so they will stack if you hit the humanoid repeatedly and all print at the same time when it dies. I suppose the most straightforward way to fix this would be to replace the event connection with an if statement:

if HitHumanoid.Health <= 0 then
	local Tag = HitHumanoid:FindFirstChild("creator")
	if Tag then
		print('died')		
	end
end

Personally, though, I think it would be more efficient to add a script within the humanoid’s character itself to detect whenever it died (using a .Died event) because then you’ll only have one copy of it to modify if you need to update it.

1 Like