Advertisement
IHATEMICROWAVEOVEN

Targetting Module

Aug 3rd, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local curtargets = {}
  3.  
  4.  
  5. -- Adding targets (other) (not damage-based)
  6. coroutine.wrap(function()
  7. while true do
  8. break
  9. end
  10. end)()
  11.  
  12. -- Removing targets (other) (not sight-based)
  13. coroutine.wrap(function()
  14. while true do
  15. break
  16. end
  17. end)()
  18.  
  19. -- Removing targets (on-death)
  20. script.Parent.Humanoid.Died:Connect(function()
  21. table.clear(curtargets)
  22. for _, i in pairs(script:GetChildren()) do
  23. i:Destroy()
  24. end
  25. end)
  26.  
  27. -- Adding targets (on-hit) and removing targets (range)
  28. return {
  29. Offender = function(PlayName)
  30. if not table.find(curtargets,PlayName) then
  31. local new = Instance.new("BoolValue", script)
  32. new.Name = PlayName
  33. table.insert(curtargets,PlayName)
  34. end
  35. return nil
  36. end;
  37.  
  38. Range = function(MyRange)
  39. coroutine.wrap(function()
  40. while true do
  41. wait(5)
  42. if not script.Parent:FindFirstChild("Humanoid") then break end
  43. for _, i in pairs(curtargets) do
  44. if (script.Parent.Torso.Position - workspace:FindFirstChild(i).Torso.Position).Magnitude > MyRange then
  45. table.remove(curtargets, table.find(curtargets,i))
  46. script:FindFirstChild(i):Destroy()
  47. end
  48. end
  49. end
  50. end)()
  51. return nil
  52. end;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement