How to find the killer of a humanoid, and store it in a value

From the killer

If you kill Player 1, Player 2 will get a point. If the points awarded are based on the player’s proximity to the killed player, then this is incorrect.

You must use the tagging system in the weapon

This code when placed inside a Script in StarterPlayer in StarterCharacterScripts

local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.Died:connect(function()
	
local tagging = script.Parent:FindFirstChild("CreatorKill")	
if tagging ~= nil then
if tagging.Value ~= nil then	
local Leaderstats = tagging.Value:findFirstChild("leaderstats") 
if Leaderstats ~= nil then 
Leaderstats.Kill.Value = Leaderstats.Kill.Value + 1 
Leaderstats.Coins.Value = Leaderstats.Coins.Value + 10			
script:Destroy() 
end			
end
end
	
end)

This code is when placed inside a script in the Weapon Kill function

local tagging = Instance.new("ObjectValue")
tagging.Value = dealer 
tagging.Name = "CreatorKill"
tagging.Parent = target.Parent
game:GetService("Debris"):AddItem(tagging,.5)

I used this system in a game that I play with my friends

Scripts or Local Scripts? I think you mean server-side scripts, just making sure.

Actually, never mind. I’m going to use the system provided by @IProgramForFun because I’m making an RPG game, and I don’t plan on adding ranged weapons anytime soon.

1 Like

I just wanted to help and alert you to the standard way of calculating points

I wish you good luck in what you do

Thx! I appreciate your civil manner even after I turned down your script.

1 Like