How can i add a creator tag to my custom weapon

Hi! , ill go straight to the point

  1. What do you want to achieve? I want to make my own killcam system but i dont know how to add the creator tag to my custom weapons, which i need for the killcam to recognize them

  2. What is the issue? look, i made this little client sided script that detects when a player dies and prints a message if it got killed by someone

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    yeah but i didnt find any forums with a problem similar to mine, i also tried fixing the issue by myself, creating the tag on the explorer and then assigning its value via script but that didnt work, i didnt really know what i was doing tbh

ive read that that creator tag stuff should be dealth in scripts with the damage handling and stuff, i dont know if this really helps but ill heave the damage handling script here anyway

local RS = game:GetService("ReplicatedStorage")
local onHitevent = script.Parent.HitboxNDamage

onHitevent.OnServerEvent:Connect(function(plr, hitHum)
	if not hitHum then return end
	
	local hitSound = RS.Weapons.MetalBat.BatHitSound:Clone()
	
	hitSound.Parent = hitHum.Parent
	hitSound:Play()
	
	local RandomCritChance = math.random()
	
	if RandomCritChance > 0.12 then
		hitHum:TakeDamage(10)
	else
		local CritSound = RS.Weapons.MetalBat.BatCritSound:Clone()
		local CritParticle = RS.Weapons.MetalBat.CritHitParticle:Clone()
		
		CritSound.Parent = hitHum.Parent
		CritSound:Play()
		
		CritParticle.Parent = game.Workspace
		CritParticle.Position = hitHum.Parent.Head.Position
		
		hitHum:TakeDamage(30)
	end
	
	local knockback = Instance.new("BodyVelocity")
	knockback.P = math.huge
	knockback.Parent = hitHum.Parent.HumanoidRootPart
	knockback.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	knockback.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 12
	wait(0.2)
	knockback:Destroy()
end)

Generally what you want to do when doing that is having the damage handler script check to see if the person that it hit has died.

In my opinion, I prefer checking to see if the health of the hit player hit 0 after the damage part of the script changes the health, then adding the creator tag.

Here is what should work. Just add the if statement below the damage applier statement and insert your code for the kill-cam tagging.

if RandomCritChance > 0.12 then
		hitHum:TakeDamage(10)
	else
		local CritSound = RS.Weapons.MetalBat.BatCritSound:Clone()
		local CritParticle = RS.Weapons.MetalBat.CritHitParticle:Clone()

		CritSound.Parent = hitHum.Parent
		CritSound:Play()

		CritParticle.Parent = game.Workspace
		CritParticle.Position = hitHum.Parent.Head.Position

		hitHum:TakeDamage(30)
	end
	
	if hitHum.Health <= 0 then
		-- Add scripting here that adds the tag/attribute on who killed them here
	end

kept searching and it ended up working, had to grab the classic sword creator tag function script and paste it on my code, then execute the tag and untag functions every time i hit something with the bat, still, thanks for your advice

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.