I need help with my Kills and Deaths leaderboard[SOLVED]

  1. What do you want to achieve?
    I want to achieve that if a player Kills another player, it addes a kill to his leaderstats. And a death to the other players death stat.
  2. What is the issue?
    The deaths work fine but the kills do not add up, strangly enough is that the script worked till yesterday evening. But all of a sudden it stopped working.
  3. What solutions have you tried so far?
    I have tried to rescript it, I have searched for post on the developer forum about this and I have searched for tutorials on youtube.

Extra detail:
It stopped working after I published a new update to the game. The script worked for more than 3 months.
Please excuse me if I did something wrong, this is my first ever post on here.
The script

local Players = game.Players

local Template = Instance.new 'BoolValue'
Template.Name = 'leaderstats'

Instance.new('IntValue', Template).Name = "Kills"
Instance.new('IntValue', Template).Name = "Deaths"


Players.PlayerAdded:connect(function(Player)
	wait(1)
	local Stats = Template:Clone()
	Stats.Parent = Player
	local Deaths = Stats.Deaths
	Player.CharacterAdded:connect(function(Character)
		Deaths.Value = Deaths.Value + 1
		local Humanoid = Character:FindFirstChild "Humanoid"
		if Humanoid then
			Humanoid.Died:connect(function()
				for i, Child in pairs(Humanoid:GetChildren()) do
					if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
						local Killer = Child.Value
						if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
							local Kills = Killer.leaderstats.Kills
							Kills.Value = Kills.Value + 1
						end
						return 
					end
				end
			end)
		end
	end)
end)

1 Like

You typed this wrong I think

You typed it right here tho?

It would be like this Instance.new("BoolValue").

Also, I would recommend using a folder or configuration to hold values, instead of another value.

This is wrong.

Here:

if Killer:FindFirstChild('leaderstats') and Killer.leaderstats:FindFirstChild("Kills") then

Also here:

Correct is:

local Humanoid = Character:FindFirstChild("Humanoid")

Again Correct is:

local Template = Instance.new('BoolValue')

Don’t forget the Tuples.

I will try this now, thank you for the answer.