Explanation
Alright, this is a bit of a weird one but I want to be able to record when someone kills another person; what I mean by this is, if say Player1 Killed Player2, Player1 would get a point on a leaderboard stat for Knockouts and vice versa.
Issue
The only way I know how to is quite problematic. My only knowledge of how to do something like this properly is to add a object value into the Humanoid and have the value set to the player who kills them, however this then cause for a spam of these Values to come into play.
Fixes I tried
I tried adding a check value but then it didn’t always record the value as it was blanking itself, plus if I keep it in the humanoid for too long and that person dies, it will give a free fall to the said person who last attacked him. Which I also want to prevent.
Tag Script
This is the script functions I’m using, it can be used with a Sword Tool in a sense as I’m basing it off of that.
["mark player"] = function(Hum)
local Hum = Hum:WaitForChild("Humanoid")
local Holder = game.Players:GetPlayerFromCharacter(Tool.Parent)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = Holder
creator_tag.Name = "creator"
creator_tag.Parent = Hum
end
;
["unmark player"] = function(Hum)
Hum = Hum:WaitForChild("Humanoid")
if Hum ~= nil then
local CreatorTag = Hum:FindFirstChild("creator")
if CreatorTag ~= nil then
CreatorTag.Value = nil
end
end
end
Tool.Handle.Touched:Connect(function(hit)
if hit.Parent.Name ~= "Workspace" and hit.Parent.Name ~= Tool.Parent.Name and hit.Parent ~= nil then
FindFunction("Touch",hit.Parent)
end
end)
If you have any ideas, please let me know.