So I have a Kill/ Death leadeboard for my game, but it will only run once, what I mean by that is that when someone kills another player for the first kill in the server it works, but every kill after that doesn’t. There are no errors or warnings. The script is a ServerScript
inside of ServerScriptService
. Here is my code;
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Player
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Parent = leaderstats
local Deaths = Instance.new("IntValue")
Deaths.Name = "Deaths"
Deaths.Parent = leaderstats
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
Deaths.Value = Deaths.Value + 1
print(Humanoid:FindFirstChild("Killer").Value)
local tag = Humanoid:FindFirstChild("Killer")
local Killer = game.Players:FindFirstChild(tag.Value)
local KillerChar = Killer.Character or Killer.CharacterAdded:Wait()
local KillerHum = KillerChar:WaitForChild("Humanoid")
if Killer:FindFirstChild("leaderstats") and Killer.leaderstats:FindFirstChild "Kills" then
Killer.leaderstats.Kills.Value += 1
end
return
end)
end)