Kills don't count on the leaderboard!

For my game I have designed a fully working weapon and a knife with a command and there is a necessary command on the leaderboard. But when I kill someone with the knife or gun, nothing changes in the leaderboard.
Here is the review file of the game ↓
Game.rbxl (1.8 MB)

2 Likes

Did you enable api services? If you didn’t thats why your leaderboard wasnt working.

2 Likes


Yes

2 Likes

Did you check the output for any errors?

1 Like

Liderlik tablosu scriptini araç kutusundaki scriptten aldığımı düşünüyorum ve çalışmazsa zaten altında kırmızı yazı var, komutlar doğru. Bıçak ve silaha gelince, gayet iyi çalışıyor.

1 Like

Please see the game’s review file.
Game.rbxl (1.8 MB)

2 Likes

What does the error say on the output? If you tell me i can help you fix the script.

1 Like

The knife and the gun are working, I will give you the leaderboard. The file that saves it is fine, but the leaderboard seems to be slightly faulty, not all of them are red, but some are. I’ll send it right away.


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

Instance.new('IntValue', Template).Name = "Oldurmeler"
Instance.new('IntValue', Template).Name = "Olmeler"


Players.PlayerAdded:connect(function(Player)
	wait(1)
	local Stats = Template:Clone()
	Stats.Parent = Player
	local Olmeler = Stats.Olmeler 
	Player.CharacterAdded:connect(function(Character)
		Olmeler.Value = Olmeler.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 "Oldurmeler" then
							local Oldurmeler = Killer.leaderstats.Oldurmeler
							Oldurmeler.Value = Oldurmeler.Value + 1
						end
						return -- Only one player can get a KO for killing a player. Not 2, not 3. Only one.
					end
				end
			end)
		end
	end)
end)```.

--Since English is not my first language, I put the value of Oldurmeler for all of them instead of kills
1 Like

Olmeler = Deaths
Oldurmeler = Kills

1 Like

I believe leaderstats should be a folder and not a boolean value.

Your script itself seems fine aside from the leaderstats setup, are you actually creating the object value responsible for saving a players killer?

1 Like

I already have a command like this, what I really want to say is that although the knives and weapons work and the necessary code for the leaderboard is written, the number does not increase, although the review file of the game ↓
Game.rbxl (1.8 MB)

1 Like

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 – Only one player can get a KO for killing a player. Not 2, not 3. Only one.
end
end
end)
end
end)
end)

1 Like

The problem lies with how you’re determining a players killer. You check for an object value inside the players humanoid after a player respawns which doesn’t work because the dead character is discarded when respawning, You have to save the object value for a players killer under the player instead so that it isn’t deleted when a player respawns.

2 Likes


The code you provided does not work and there seems to be a large error.

1 Like

Yes, that is the problem. When the player dies, the deaths are added to the value (Olmeler). But when a killer kills with a gun or knife, there is no improvement.

1 Like

I already provided you with the solution. Don’t save the killer under the Humanoid as it gets deleted when the character respawns. Save it under the Player instance instead.

1 Like

I am not very good at the command, I already wrote that command very difficult, can you give me a script?

1 Like

Is this leaderboard local to each server or global to all servers?

1 Like

This command saves who has killed how much and who has died how much on all servers, the problem is that this number does not increase and there is another command that saves it and it is fine. So basically on all servers

1 Like