For some reason, when you kill another player, it just wont add +1 kill to the leaderstats. Any help?
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
player.Character.Humanoid.Died:Connect(function()
local humanoid = player.Character:WaitForChild("Humanoid")
local tag = humanoid:FindFirstChild("creator")
if tag and tag.Value then
local playername = tag.Value
local killer = game:GetService("Players"):FindFirstChild(playername.Name)
killer.leaderstats.Kills.Value += 1
end
end)
end)
end)
What have you done to debug this code? It also seems as if the âcreatorâ instance is an ObjectValue, which suggests it holds a Player instance. If this is the case, why are you deriving them again by searching for them under the Players service via Instance:FindFirstChild?
(If you find that there is no value tied to the ObjectValue, then your weapons are at fault)
I think he isnt being very clear on how all the code works he is only portraying one script than the scripts that actually link together such as him coding the leaderstats script and the tool or tools that create the object value
Try this code if it doesnt help then other code or scripts are affecting this script:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Char)
local humanoid = Char:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
local tag = humanoid:FindFirstChild("creator")
if tag and tag.Value then
local killer = tag.Value
local leaderstats=killer:FindFirstChild("leaderstats")
if leaderstats and leaderstats:FindFirstChild("Kills") then
leaderstats.Kills.Value += 1
end
end
end)
end)
end)