Where/how would I add in a Creator tag into my gun?

I have a gun, but I dont know how to add a ‘Creator Tag’ or have much information on it. I am trying to make a kill cam for my game but I also need a Creator tag to be implemented into the gun for it to work. I just dont know how to write one or what they look like very much. There are only two youtube tutorials that reference it.

Can someone help me and tell me how to write it or where to add it in?

  1. What do you want to achieve?

I want to add a creator tag to my gun

  1. What is the issue?

I just dont know how to write one, or where it would go

  1. What solutions have you tried so far?

Youtube, dev forum etc.

View

In the Classic sword there is a piece of script:

local Debris = game:GetService("Debris")

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

Script from my gun:

local ply = game.Players.LocalPlayer

local tip = script.Parent.Tip

script.Parent.Fire.OnServerEvent:Connect(function(player, mousePos)
	if player.Character.Humanoid.Health > 0 then
		script.Parent.GS:Play()
		
		local rayorigin = tip.CFrame.p
		local raydirection = (mousePos - tip.CFrame.p).unit * 300
		
		local raycastparams = RaycastParams.new()
		raycastparams.FilterDescendantsInstances = {player.Character}		
		raycastparams.FilterType = Enum.RaycastFilterType.Blacklist		

		local result = workspace:Raycast(rayorigin, raydirection, raycastparams)
		
		if result then
			local hitpart = result.Instance
			local humanoid = hitpart.Parent:FindFirstChild("Humanoid")
			
			
			local bullet = Instance.new("Part")
			bullet.Parent = game.Workspace.BulletHolder
			bullet.BrickColor = BrickColor.new("White")
			bullet.Material = Enum.Material.Neon
			bullet.CanCollide = false
			bullet.Anchored = true
			
			local distance = (tip.CFrame.p - hitpart.Position).magnitude
			bullet.Size = Vector3.new(0.15,0.15, distance)
			bullet.CFrame = CFrame.new(tip.Position, mousePos) * CFrame.new(0,0, -distance/2)
			
			if not humanoid then
				humanoid = hitpart.Parent.Parent:FindFirstChild("Humanoid")
			end
			
			if humanoid then
				player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1
				wait(.1)
				player.leaderstats.Streak.Value = player.leaderstats.Streak.Value + 1
				wait(.1)
				player.leaderstats.Gems.Value = player.leaderstats.Gems.Value + math.random(2, 7)
				
				local hitpartdistance = (player.Character.HumanoidRootPart.Position - humanoid.RootPart.Position).magnitude
				humanoid:TakeDamage(100)
			end
			game:GetService("Debris"):AddItem(bullet, 0.1)
		end
	end
end)

Does anyone know where/how I can add in a Creator Tag??? This would help me out so much!

4 Likes

I’m assuming the point of the creator tag is so you can’t hit yourself. However since firing and damaging is done from the same script, just add to your hit statement:

if humanoid and game.Players:GetPlayerFromCharacter(humanoid.Parent) ~= nil and game.Players:GetPlayerFromCharacter(humanoid.Parent) ~= player then

It’s very sloppy, however what that function does is check if theres a player linked to whoever it hit. If there is, it checks if its the player who shot the bullet. However with that current method you can’t hit NPCs unless you alter the if statement to account for that, like if there is not player then deal damage.

if humanoid and game.Players:GetPlayerFromCharacter(humanoid.Parent) ~= nil and game.Players:GetPlayerFromCharacter(humanoid.Parent) ~= player or humanoid ~= nil then

Something like that. But if thats not what you’re looking to do with a “creator tag” please elaborate further, 'cause I’d be lost then. :sweat_smile:

1 Like

Thanks for the reply. But from what I have read, A creator tag is an (old) roblox feature that allows you to add kills and deaths. Or something similar. I dont really know much but I need it for my kill cam to work. Its in the Roblox Classic sword which I pasted the piece of script above. But I just dont know where to implement it or where to write it, or how to write it

1 Like

Ohhhhh, I see. From what I looked up and I’ve done something similar in the past. What people do is when you deal damage. You create that tag somewhere in the attacked player/npcs character model. I saw an example of putting it in their Humanoid. I’d probably make a folder in their character to hold it. And when you hit them create an object value called “CreatorTag” or something and parent it into that folder. Once that person dies put a humanoid.Died event on their character that checks said folder for the CreatorTag to read who killed them.

However, looking at your code, since you already give kills, streak, and gems on hit, I don’t know what the purpose of the tag would be for. It’d tell the person who died who killed them if you’re wanting that.

1 Like

Yeah I guess. But for some reason my kill cam wont work without it. There is a humanoid.Died in the leaderstats:

local StreakDeathValue  = 0

player.CharacterAdded:Connect(function(character)
		local humanoid = character:FindFirstChild("Humanoid")

		humanoid.Died:Connect(function(died)
			
			Streak.Value = StreakDeathValue
		end)
	end)

(Thats only a fragment of the leaderstats script)

The main problem, is, I dont know how to put in a folder in the character or anything like that since ive never really tried doing it.

1 Like

Since you already have player.CharacterAdded, it’s really simple from there.

player.CharacterAdded:Connect(function(character)
        local killFolder = Instance.new("Folder")
        killFolder.Parent = character
        killFolder.Name = 'KillFolder'

		local humanoid = character:FindFirstChild("Humanoid")

		humanoid.Died:Connect(function(died)
			
		Streak.Value = StreakDeathValue
	end)
end)

That places the kill folder in the player’s character every time they respawn. Does your kill cam work currently? Or is it broken as is? Because if not, it’d be really easy to figure out how to get the killer once the tag systems up and running.

1 Like

I dont know what this would be for? But the script for the Kill cam is here:

local camera = game.Workspace.CurrentCamera
local frame = script.Parent.Frame
local back = script.Parent.Back

local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

hum.Died:Connect(function()
	local murderer = char.Humanoid:FindFirstChild("creator") ***
	local murdererName = murderer.Value
	
	if murderer.Value == game.Players.LocalPlayer.Name then
		frame.Visible = true
		back.Visible = true
		camera.CameraSubject = hum
		frame.Killer.Text = murdererName.."!"
		wait(3)
		frame.Visible = false
		back.Visible = false
		camera.CameraSubject = hum
	end
end)

***Where it says this, this is where I believe it is referencing the ‘Creator Tag’. Its looking for the user that killed the user that died. The ‘Killer’ would have the creator tag.

1 Like

I entirely see how this works. Ok.

First off, forget about using the folder part of the script. When you hit a player, create an object in the humanoid called creator and put your player as the value.

The way that kill cam script works is kind of weird though, it only works if you’re the killer?

I dont entirely know what you mean by this-

Well, if you killed the player, you would have the creator tag. Im pretty sure it looks for the Creator tag in the user then makes the user that died spectate that user that has killed the other user, as long as they have a creator tag.

The folder part was a misinterpretation on my end, its not necessary. However the kill cam script only checks for your humanoid and checks if you died. Then if you died it looks for that creator tag and if it exists it checks if the killers name is your name. Then it fires.

Also this line wouldn’t work because you’re comparing an player object with a string value.

Yeah, Im not sure. I watched a tutorial for the kill cam because i had no prior knowledge of doing it. And i was/am still learning to script.

All good. You have it down almost perfectly though, theres just a few things that are incorrect.

hum.Died:Connect(function()
	local murdertag = char.Humanoid:FindFirstChild("creator")
	local murderer = murdertag.Value
	
	if murderer ~= nil and murderer ~= game.Players.LocalPlayer then
        local murdererHum = murderer.Character.Humanoid        

		frame.Visible = true
		back.Visible = true
		camera.CameraSubject = murdererHum
		frame.Killer.Text = murderer.Name.."!"
		wait(3)
		frame.Visible = false
		back.Visible = false
		camera.CameraSubject = hum
	end
end)

This should somewhat fix it I believe, only way is to test. However back to that creator tag issue. Since you already have the kill script where you give gems, kills, and streaks, you’d wanna add this into that part too.

local killTag = Instance.new("ObjectValue")
killTag.Parent = humanoid
killTag.Name = 'creator'

Thanks! Hopefully it should work :smile:

Would I put this in the kill cam script or the leaderstats piece of mine?

In the original script from this post, the one that kills the player and give gems.

Alright. Ill have a look! Thank you.

@Ziraun

I have added in the small piece of script that you gave me. And I changed the kill cam script, nothing has changed im afraid :frowning:

1 Like

Can exploiter’s read the script? @Ziraun
Also im a friend of Lightz.

Are there any errors in the output?

Only the killcam part. Exploiters can read every client script even if you’ve deleted them or set them to nil.

I can ask one of my developers if they can take a screenshot of the Developer console. Thats it, I cant really test in studio right now