I have been trying to write a script that updates a players kills in their leaderstats but it won’t. The Output keeps saying Kills is nil~, Please take a look and help because I’m sure it’s an easy mistake.
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild(“Humanoid”)
Humanoid.Died:connect(function()
if Humanoid:FindFirstChild(“creator”) ~= nil then
local Killer = Humanoid.creator.Value
game.Players.Killer.leaderstats.Kills.Value = game.Players.Killer.leaderstats.Kills.Value + 1
end
end)
It is because you are referring to the player as game.Players.Killer but instead you should be using game.Players[Killer]
But…
If Killer is equal to the player itself, you just need to use Killer, without using game.Players. But if Killer is a StringValue, use what I said above.