-
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. -
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. -
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)