Advertisement
Real_IceyDev

Kill Feed & KIll Leaderboard - Roblox Script

Jun 3rd, 2021
2,391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.47 KB | None | 0 0
  1. -- Made by Real_IceyDev (lceyDex) --
  2. -- This is my kill feed & kill leaderboard, you shouldn't take this if you don't know how to properly edit it. It's meant as a showcase lol --
  3.  
  4. victimname = "Player1"
  5. killname = "Player2"
  6.  
  7. function update()
  8.  
  9. player = game.Players:GetChildren()
  10. for i = 1, #player do
  11. up = player[i].PlayerGui.Update
  12. up1 = up.Up1
  13. up2 = up.Up2
  14. up3 = up.Up3
  15. up4 = up.Up4
  16. up5 = up.Up5
  17. up1.Text = up2.Text
  18. up2.Text = up3.Text
  19. up3.Text = up4.Text
  20. up4.Text = up5.Text
  21. up5.Text = "" ..victimname.. " was killed by " ..killname.. ""
  22. end
  23.  
  24. ups = game.StarterGui.Update
  25. ups1 = ups.Up1
  26. ups2 = ups.Up2
  27. ups3 = ups.Up3
  28. ups4 = ups.Up4
  29. ups5 = ups.Up5
  30. ups1.Text = ups2.Text
  31. ups2.Text = ups3.Text
  32. ups3.Text = ups4.Text
  33. ups4.Text = ups5.Text
  34. ups5.Text = "" ..victimname.. " was killed by " ..killname.. ""
  35.  
  36. end
  37.  
  38. function onPlayerEntered(newPlayer)
  39.  
  40.  
  41. local stats = Instance.new("IntValue")
  42. stats.Name = "leaderstats"
  43.  
  44. local score = Instance.new("IntValue")
  45. score.Name = "Kills"
  46. score.Value = 0
  47.  
  48. local spree = Instance.new("IntValue")
  49. spree.Name = "Deaths"
  50. spree.Value = 0
  51.  
  52. score.Parent = stats
  53. spree.Parent = stats
  54.  
  55.  
  56. while true do
  57. if newPlayer.Character ~= nil then break end
  58. wait(5)
  59. end
  60.  
  61. local humanoid = newPlayer.Character.Humanoid
  62. humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )
  63. newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
  64. stats.Parent = newPlayer
  65. end
  66.  
  67.  
  68.  
  69. function Send_DB_Event_Died(victim, killer)
  70. local killername = "no one"
  71. if killer ~= nil then killername = killer.Name end
  72. print("DIED EVENT: ", victim.Name, " KILLED by ", killername)
  73.  
  74. victimname = victim.Name
  75. killname = killername
  76.  
  77. update()
  78.  
  79. if shared["deaths"] ~= nil then
  80. shared["deaths"](victim, killer)
  81. print("SENT DB DEATH EVENT")
  82. end
  83. end
  84.  
  85. function Send_DB_Event_Kill(killer, victim)
  86. print("KILL EVENT. ", killer.Name, " BLOXXED ", victim.Name)
  87. if shared["kills"] ~= nil then
  88. shared["kills"](killer, victim)
  89. print("SENT DB KILL EVENT")
  90. end
  91. end
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. function onHumanoidDied(humanoid, player)
  100. local stats = player:findFirstChild("leaderstats")
  101. if stats ~= nil then
  102. local score = stats:findFirstChild("Kills")
  103. local spree = stats:findFirstChild("Deaths")
  104. spree.Value = 0
  105. score.Value = score.Value - 1
  106.  
  107. local killer = getKillerOfHumanoidIfStillInGame(humanoid)
  108. Send_DB_Event_Died(player, killer)
  109. handleKillCount(humanoid, player)
  110. end
  111. end
  112.  
  113.  
  114.  
  115. function onPlayerRespawn(property, player)
  116. if property == "Character" and player.Character ~= nil then
  117. local humanoid = player.Character.Humanoid
  118. local p = player
  119. local h = humanoid
  120. humanoid.Died:connect(function() onHumanoidDied(h, p) end )
  121. end
  122. end
  123.  
  124.  
  125.  
  126. function getKillerOfHumanoidIfStillInGame(humanoid)
  127. local tag = humanoid:findFirstChild("creator")
  128. if tag ~= nil then
  129. local killer = tag.Value
  130. if killer.Parent ~= nil then
  131. return killer
  132. end
  133. end
  134. return nil
  135. end
  136.  
  137.  
  138. function handleKillCount(humanoid, player)
  139. local killer = getKillerOfHumanoidIfStillInGame(humanoid)
  140. if killer ~= nil then
  141. local stats = killer:findFirstChild("leaderstats")
  142. if stats ~= nil then
  143. local score = stats:findFirstChild("Kills")
  144. local spree = stats:findFirstChild("Deaths")
  145. score.Value = score.Value + 2
  146. spree.Value = spree.Value + 1
  147. else
  148. spree.Value = 0
  149. score.Value = score.Value - 1
  150. end
  151. Send_DB_Event_Kill(killer, player)
  152. end
  153. end
  154.  
  155.  
  156.  
  157. game.Players.ChildAdded:connect(onPlayerEntered)
  158.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement