Advertisement
Janelijs

Kills/Death Script

Jul 6th, 2023
55,787
3
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 3 0
  1. Kills/Deaths script:
  2.  
  3.  
  4. local Players = game.Players
  5.  
  6. Players.PlayerAdded:Connect(function(player)
  7.    
  8.     local leaderstats = Instance.new("Folder")
  9.     leaderstats.Name = "leaderstats"
  10.     leaderstats.Parent = player
  11.    
  12.     local kills = Instance.new("IntValue")
  13.     kills.Name = "Kills"
  14.     kills.Value = 0
  15.     kills.Parent = leaderstats
  16.    
  17.     local Deaths = Instance.new("IntValue")
  18.     Deaths.Name = "Deaths"
  19.     Deaths.Value = 0
  20.     Deaths.Parent = leaderstats
  21.    
  22.     wait(1)
  23.     local Stats = leaderstats:Clone()
  24.     Stats.Parent = player
  25.     player.CharacterAdded:connect(function(Character)
  26.         local Humanoid = Character:FindFirstChild "Humanoid"
  27.         Deaths.Value = Deaths.Value + 1
  28.         if Humanoid then
  29.             Humanoid.Died:connect(function()
  30.                 for i, Child in pairs(Humanoid:GetChildren()) do
  31.                     if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
  32.                         local Killer = Child.Value
  33.                         if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
  34.                             local Kills = Killer.leaderstats.Kills
  35.                             Kills.Value = Kills.Value + 1
  36.                         end
  37.                         return
  38.                     end
  39.                 end
  40.             end)
  41.         end
  42.     end)
  43. end)
Advertisement
Comments
  • vicon23
    210 days (edited)
    # Lua 1.10 KB | 0 0
    1. local Players = game.Players
    2.  
    3. Players.PlayerAdded:Connect(function(player)
    4.  
    5.     local kills = Instance.new("IntValue")
    6.     kills.Name = "Kills"
    7.     kills.Value = 0
    8.     kills.Parent = leaderstats
    9.  
    10.     local Deaths = Instance.new("IntValue")
    11.     Deaths.Name = "Deaths"
    12.     Deaths.Value = 0
    13.     Deaths.Parent = leaderstats
    14.  
    15.     wait(1)
    16.     local Stats = leaderstats:Clone()
    17.     Stats.Parent = player
    18.     player.CharacterAdded:connect(function(Character)
    19.         local Humanoid = Character:FindFirstChild "Humanoid"
    20.         Deaths.Value = Deaths.Value + 1
    21.         if Humanoid then
    22.             Humanoid.Died:connect(function()
    23.                 for i, Child in pairs(Humanoid:GetChildren()) do
    24.                     if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
    25.                         local Killer = Child.Value
    26.                         if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
    27.                             local Kills = Killer.leaderstats.Kills
    28.                             Kills.Value = Kills.Value + 1
    29.                         end
    30.                         return
    31.                     end
    32.                 end
    33.             end)
    34.         end
    35.     end)
    36. end)
    37.  
    38. If I already have the leaderstats "Folder" thingy should I make it this? Or should I make it a different way? ^
Add Comment
Please, Sign In to add comment
Advertisement