Hello, so im trying to make a game my cousin suggested to me, and it has the kill and death script for the leaderstats, when you die, your deaths go up but when you get a kill, it stays at 0.
Heres the script!
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr
local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = stats
local deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Parent = stats
plr.CharacterAdded:connect(function(char)
local humanoid
repeat
humanoid = char:FindFirstChild("Humanoid")
wait()
until humanoid
humanoid.Died:connect(function()
deaths.Value = deaths.Value + 1
local tag = humanoid:FindFirstChild("creator")
if tag then
local killer = tag.Value
if killer then
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
end
end
end)
end)
end)
I would recommend instead of using this inside of the leaderstats script, make a script sort of like this inside of the tool/weapon instead. This can be buggy with self-made tools.