I have an IntValue inside the player that is a kill counter that adds one number for every kill someone does. When i try killing another player, it returns with the error: "attempt to index local 'player' (a nil value)". How can i fix this?
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
char.Humanoid.Died:connect(function()
if char.Humanoid:FindFirstChild("creator") ~= nil then
local tag = Instance.new("StringValue")
tag.Value = char.Humanoid.creator.Name
local player = game.Players:FindFirstChild(tag.Value)
player.KillCounter.Value = player.KillCounter.Value + 1
tag:Destroy()
end
end)
end)
end)

2 comments
Because player wasn't found.
so how can i change it to find the player?