I have a leaderboard that has Kills and Deaths and for some reason, it only adds to the deaths when a player dies but it doesn't add to the killer's kills. Why isn't it working?
player.CharacterAdded:Connect(function(Character) local Humanoid = Character:FindFirstChild("Humanoid") Humanoid.Died:Connect(function(Died) Deaths.Value += 1 local Tag = Humanoid:FindFirstChild("creator") local Killer = Tag.Value if Tag and Killer then -- wont work Killer.LeaderStats:FindFirstChild("Kills").Value += 1 end end) end)
You should loop through all the players' characters to see if they're a killer or not.
player.CharacterAdded:Connect(function(Character) local Humanoid = Character:FindFirstChild("Humanoid") Humanoid.Died:Connect(function(Died) Deaths.Value += 1 for i, v in pairs(game.Players:GetPlayers()) do -- loops through all the players local Tag = v.Character.Humanoid:FindFirstChild("creator") if Tag then local Killer = Tag.Value if Killer then Killer.LeaderStats:FindFirstChild("Kills").Value += 1 break end end end end) end)