Hello!
I wanted to make a kills and deaths storing system in my game but I’m not sure how to start.
I want the code to later be able to be put in a GUI that will show the deaths and kills for that 1 player,
I am using ACS weapon system, to clear things up; this toolbox script works for kills and deaths perfectly:
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 -- Only one player can get a KO for killing a player. Not 2, not 3. Only one.
end
end
end)
end
end)
end)
Coded by JulienDethurens
also, in the future there will be a custom leaderboard (the one that’d appear when u press tab and a gui would appear or something, but thats for the future, not sure if i would be able to make one using roblox default leaderboard system