Just by looking at what you said about the rewarding not working for the killer, and a quick glimpse of the code, I can think of a few solutions.
The first thing is, we set âtagâ to a :FindFirstChild(âcreatorâ) as shown below:
local tag = humanoid:FindFirstChild("creator")
And then below, you instantly set killer to âtag.Valueâ without actually reassuring that tag actually is an object (as at this point, :FindFirstChild() could have returned nil).
local tag = humanoid:FindFirstChild("creator")
local killer = tag.Value -- For all we know, tag could be nil, and nil doesn't have a .Value property.
Then we go to the condition, which checks:
if tag and killer then
Which means, if tag isnât nil and killer isnât nil, then we run the code in the condition. At a guess, either tag or killer are nil (if tag is the one thatâs nil, of course killer will be too).
The most reliable way to determine if an object exists is to use :WaitForChild() with a timeout (so it doesnât wait infinitely for an object to be found) and then handle accordingly what happens in the eventuality that returned object is nil.
player.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid", 2)
if humanoid then
humanoid.Died:Connect(function()
Deaths.Value = Deaths.Value + 1
local tag = humanoid:WaitForChild("creator", 2)
if not tag then
--[[ We could construct a new object to put in the humanoid here,
but will error and return here as we can't continue. ]]
error("Failed to find "creator" object in the Humanoid.")
return
end
local killer = tag.Value
if tag and killer then
killer.leaderstats:FindFirstChild("Kills").Value += 1
killer:FindFirstChild("RoundKills").Value += 1
end
end)
end
end)
So overall, my guess as to why it doesnât work is because tag is nil, so wonât get into the condition, itâs probably erroring on the local killer = tag.Value line, saying that thereâs no .Value property of nil.
Let me know if it works and if you have any questions. 