My leaderboard wont show kills or deaths it only shows Value

	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"

	local kills = Instance.new("NumberValue",leaderstats)
	kills.name = "Kills"
	kills.Value = 0

	local deaths = Instance.new("NumberValue",leaderstats)
	deaths.Name = "Deaths"
	deaths.Value = 0

	player.CharacterAdded:Connect(function(character)
		local humanoid = character:FindFirstChild("Humanoid")

		humanoid.Died:Connect(function(died)
			deaths.Value = deaths.Value + 1
			local tag = humanoid:FindFirstChild("creator")
			local killer = tag.Value 
			if tag and killer then
				killer.leaderstats:FindFirstChild("Kills").Value = kills.leaderstats:FindFirstChild("Kills").Value + 1
			end
		end)
	end)
end)

Try using this code for your script:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr

	local kills = Instance.new("NumberValue")
	kills.Name = "Kills"
	kills.Value = 0
	kills.Parent = leaderstats
	
	local deaths = Instance.new("NumberValue")
	deaths.Name = "Deaths"
	deaths.Value = 0
	deaths.Parent = leaderstats

	plr.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")

		hum.Died:Connect(function()
			deaths.Value += 1
			local tag = hum:FindFirstChild("creator")
			
			if tag then
				local killer = tag.Value
				killer.leaderstats:FindFirstChild("Kills").Value += 1
			end
		end)
	end)
end)
2 Likes

thank you so much!! What did you change?

1 Like

You had the N for name lowercased, and you also tried putting the parent of the leaderstats and values when creating them. That was the problem, and that is what I fixed.

Your original code:

	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"

	local kills = Instance.new("NumberValue",leaderstats)
	kills.name = "Kills" -- lowercase 'n'
	kills.Value = 0

	local deaths = Instance.new("NumberValue",leaderstats)
	deaths.Name = "Deaths"
	deaths.Value = 0

Fixed Code:

	local leaderstats = Instance.new("Folder") -- removed the parent from here
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr -- and added a separate line of code

	local kills = Instance.new("NumberValue")
	kills.Name = "Kills" -- now changed to uppercase 'N'
	kills.Value = 0
	kills.Parent = leaderstats
	
	local deaths = Instance.new("NumberValue")
	deaths.Name = "Deaths"
	deaths.Value = 0
	deaths.Parent = leaderstats
2 Likes