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)
Did you enable api services? If you didn’t thats why your leaderboard wasnt working.
Did you check the output for any errors?
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.
What does the error say on the output? If you tell me i can help you fix the script.
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
Olmeler = Deaths
Oldurmeler = Kills
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?
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)
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)
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.
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.
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.
I am not very good at the command, I already wrote that command very difficult, can you give me a script?
Is this leaderboard local to each server or global to all servers?
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