How to use Creator tag in weapons?

I’m trying to make a sword that gives you points for every player you kill, while researching, I found something called “creator tags” in most of Roblox’s gears. I understand what it does but what I want to do is figure out how to implement it in my sword.

local Damage = script.Parent.Values.Damage.Value

local tool = script.Parent
local Trail = script.Parent.Trail

local idleAnim = script.Animations:WaitForChild("Idle")
local idleAnimTrack
local swingAnim = script.Animations:WaitForChild("Swing")
local swingAnimTrack
local swingAnim = script.Animations:WaitForChild("Swing")

local slashSound = script:WaitForChild("SlashSound")
local sheathSound = script:WaitForChild("SheathSound")
local hitSound = script:WaitForChild("HitSound")

local hitCharacters = {}
local debounce = false

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

tool.Equipped:Connect(function()
	
	local humanoid = script.Parent.Parent.Humanoid
	if not idleAnimTrack then idleAnimTrack = humanoid:LoadAnimation(idleAnim) end
	
	idleAnimTrack:Play()
	
	sheathSound:Play()
end)

tool.Unequipped:Connect(function()
	
	if idleAnimTrack then idleAnimTrack:Stop() end
	if swingAnimTrack then swingAnimTrack:Stop() end
	
	sheathSound:Play()
end)

tool.Activated:Connect(function()
	
	if debounce then return end
	debounce = true
		
	local humanoid = script.Parent.Parent.Humanoid
	if not swingAnimTrack then swingAnimTrack = humanoid:LoadAnimation(swingAnim) end
	
	swingAnimTrack:Play()
	wait(0.3)
	Trail.Enabled = true
	slashSound:Play()
	wait(0.2)
	
	Trail.Enabled = false
	
	wait(0.5)
	debounce = false
end)

tool.Hit.Touched:Connect(function(touch)
	
	if hitCharacters[touch.Parent] or not debounce then return end
	if touch.Parent:FindFirstChild("Humanoid") then
		hitSound:Play()
		touch.Parent.Humanoid:TakeDamage(Damage)
		hitCharacters[touch.Parent] = true
		wait(1)
		hitCharacters[touch.Parent] = nil
	end
end)
1 Like

Your code should be fine, you forgot to call the TagHumanoid function when the sword hit a player

1 Like

I tried that, didn’t work. Forgot to mention that I have a leaderboard script that gives the player points when a player is killed.

game.Players.PlayerAdded:connect(function(player)

	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"

	local KO = Instance.new("IntValue",leaderstats)
	KO.Name = "KO"
	KO.Value = 0


	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function(killed)

			local CreatorTag = character.Humanoid:FindFirstChild("creator")

			if CreatorTag and CreatorTag.Value then

				local stats = CreatorTag.Value:WaitForChild("leaderstats")
				stats["KO"].Value = stats["KO"].Value + 1			
			end
		end)
	end)
end)
1 Like

Creator tags were an old feature in Roblox which allowed games to keep track of how many kills a certain player has. If you’re a long time player, you’ll recall a leaderboard on each game’s page showing how many kills a certain player has. It was pretty much a connection between the game and the Roblox website to create a leaderboard in which players can view a global kill count. It was also displayed on their profiles how many kills and deaths they had on all the games they had played.

The creator tag, however, still has use today as leaderstats automatically hook to the Creator tag, this way it increases the deaths/kills of said player in the leaderboard. If you wanna know how to create a Roblox leaderboard check out here.

1 Like

You don’t need to hook functions to update the KO and WO of your players - but you have to name the values “KOs” and “WOs” in order for Roblox to automatically assign them to kill/death count.

One side note, I’m not sure if this is still a feature since it is extremely old, but you should give it a try.

Would firing an event when a player dies work?

From what I recall correctly, all you have to do is create the “KOs” and “WOs” value inside of the leaderboard and use a function to create the Creator tag inside of the Humanoid of the person that has been killed by a tool - everything else is handled automatically by Roblox.