Advertisement
Upscalefanatic3

Autokill 'Mobs' when equipping sword

Dec 11th, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Equip your sword or Play Hallow Combat - Execute this:
  2.  
  3.  
  4. local Player = game.Players.LocalPlayer
  5.  
  6. local Connections = {}
  7.  
  8. local function MakeConnection(Mob)
  9. if not Connections[Mob] and Mob:FindFirstChildOfClass("Humanoid") then
  10. local tbl = game.Players:GetPlayers()
  11. for i,v in pairs(tbl) do
  12. if Mob == v.Character then
  13. return
  14. end
  15. end
  16. Connections[Mob] = Mob.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
  17. for i = 1, 20 do
  18. Mob.Humanoid.Health = 0
  19. end
  20. end)
  21. end
  22. end
  23.  
  24. for i,v in pairs(workspace:GetDescendants()) do
  25. local Hum = v:FindFirstChild("Humanoid")
  26. if Hum then
  27. MakeConnection(v)
  28. end
  29. end
  30.  
  31. workspace.DescendantAdded:Connect(function(Child)
  32. local Hum = Child:FindFirstChild("Humanoid") or Child:WaitForChild("Humanoid", 10)
  33. if Hum then
  34. MakeConnection(Child)
  35. end
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement