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

Hi ziraun! I took a screenshot of the developer console and It is getting error’s.


I am a developer for lightz on a another account.

Which part of the killcam is line 11?

@FinlandGotTalent

Line 11 is:

 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 murdertag = char.Humanoid:FindFirstChild("creator")
	local murderer = murdertag.Value  --This line

	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)

We have also had reports from players:

I’ve just finished editing a gun system of mine so I’ll help ya out.

Here’s the creator tag function you made but working :

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

You add that function with the Player from your firing remote, and with the humanoid every time a player gets hit by a gun. That should work.

1 Like

Thank you for this. Would I add it before the event is fired or after, and any specific place?

Add that before and call that function when you kill the player.

So this is my script that fires the event, would it go here?

local mouse = game.Players.LocalPlayer:GetMouse()

script.Parent.Activated:Connect(function()
	script.Parent.Fire:FireServer(mouse.Hit.p)
	
	script.Disabled = true
	wait(0.9)
	script.Disabled = false
	
end)

On the server when you receive the command to fire. When it detects a hit and kills the player call the function there.

Sorry I dont understand- How would I do this?

In the gun script, write this.

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 and humanoid.Health > 0 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

                local Creator_Tag = Instance.new("ObjectValue")
	            Creator_Tag.Name = "creator"
	            Creator_Tag.Value = player
	            Creator_Tag.Parent = humanoid

				humanoid:TakeDamage(100)
			end
			game:GetService("Debris"):AddItem(bullet, 0.1)
		end
	end
end)

Alright. Many thanks! I am still learning to script and I still find a lot of things confusing.

Moving on from this. Thank you so much to everyone that helped! It works and its perfect.
@oSudden @hotpocket285 @FinlandGotTalent

1 Like

@hotpocket285 Hi I am here wanting to say it works! Instant respect for everyone who involved in this.