local v={}local E=game:GetService("\068\101\098\114\105\115")local F="\099\114\101\097\116\111\114"local N=1 function v.TagKiller(v,Q)assert(typeof(v)=="\073\110\115\116\097\110\099\101")assert(typeof(Q)=="\073\110\115\116\097\110\099\101")for v,E in pairs(v:GetChildren())do if E.Name==F then E:Destroy()end end local c=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")c.Name=F c.Value=Q c.Parent=v E:AddItem(c,N)return c end function v.GetKillerOfHumanoid(v)assert(typeof(v)=="\073\110\115\116\097\110\099\101")local E=v:FindFirstChild("\099\114\101\097\116\111\114")if not E then return nil end if not E:IsA("\079\098\106\101\099\116\086\097\108\117\101")then return nil end local F=E.Value if not F then return nil end if not F:IsA("\080\108\097\121\101\114")then return nil end if not F:IsDescendantOf(game)then return nil end return F end return v
--- Tags and retrieves killer
-- @module HumanoidKillerUtil

local HumanoidKillerUtil = {}

local Debris = game:GetService("Debris")

-- For legacy reasons we use creator tag
local TAG_NAME = "creator"
local TAG_LIFETIME = 1

function HumanoidKillerUtil.TagKiller(humanoid, attacker)
	assert(typeof(humanoid) == "Instance")
	assert(typeof(attacker) == "Instance")

	for _, item in pairs(humanoid:GetChildren()) do
		if item.Name == TAG_NAME then
			item:Destroy()
		end
	end

	local creator = Instance.new("ObjectValue")
	creator.Name = TAG_NAME
	creator.Value = attacker
	creator.Parent = humanoid

	Debris:AddItem(creator, TAG_LIFETIME)

	return creator
end

function HumanoidKillerUtil.GetKillerOfHumanoid(humanoid)
	assert(typeof(humanoid) == "Instance")

	local creator = humanoid:FindFirstChild("creator")
	if not creator then
		return nil
	end

	if not creator:IsA("ObjectValue") then
		return nil
	end

	local killer = creator.Value
	if not killer then
		return nil
	end

	if not killer:IsA("Player") then
		return nil
	end

	if not killer:IsDescendantOf(game) then
		return nil
	end

	return killer
end

return HumanoidKillerUtil