I have a game with sword that should register if you kill someone. The problem is when i hit other player he gets like 4 creator tags. Wich propably prevents to register killer. I have this code in my weapon and other in leaderstats

WEAPON SCRIPT

--damage
hitbox.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= tool.Parent then
		if debounce == true then
			
			--Check to make sure it's a player
			local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
			if plr then
				--Create the tag, place it in their Humanoid
				local tag = Instance.new('ObjectValue',Hit.Parent.Humanoid)
				tag.Name = 'creator'
				--Make the value your player instance
				tag.Value = plr
				--To be fair, make the tag expire.. so someone that you hit 10 minutes ago doesn't reward you a KO
				wait(3)
				tag:Destroy()
			end
			Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(3)

LEADERSTATS

p.CharacterAdded:Connect(function(c)

		c:WaitForChild("Humanoid").Died:Connect(function()
			local creator = c.Humanoid:FindFirstChild('creator')
			
			if creator ~= nil and creator.Value ~= nil then
				print("killer detected!")
				
			else
				print("CANNOT FIND KILLER!")
			end

1 comment

0

it seems like a debounce problem idk if u fixed it already or not tho