Advertisement
Vanihgol33

Ant War Kill aura ( Click the key [p] to stop

Feb 26th, 2024
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local Players = game:GetService("Players")
  3. local Player = Players.LocalPlayer
  4.  
  5. local active = true
  6.  
  7. local function getClosestPlayer()
  8. local closestDistance = math.huge
  9. local closestPlayer = nil
  10.  
  11. for _, otherPlayer in ipairs(Players:GetPlayers()) do
  12. if otherPlayer ~= Player then
  13. local character = otherPlayer.Character
  14. if character and character:FindFirstChild("HumanoidRootPart") then
  15. local distance = (character.HumanoidRootPart.Position - Player.Character.HumanoidRootPart.Position).magnitude
  16. if distance < closestDistance then
  17. closestDistance = distance
  18. closestPlayer = otherPlayer
  19. end
  20. end
  21. end
  22. end
  23.  
  24. return closestPlayer
  25. end
  26.  
  27. local function bitePlayer(targetPlayer)
  28. local args = {
  29. [1] = "Bite",
  30. [2] = targetPlayer.Character.Humanoid,
  31. [3] = targetPlayer.Character.BiteHitbox
  32. }
  33. ReplicatedStorage:WaitForChild("ServerEvents"):WaitForChild("Bite"):FireServer(unpack(args))
  34. end
  35.  
  36. local function startBiting()
  37. while wait(0.1) do
  38. if active then
  39. local targetPlayer = getClosestPlayer()
  40. if targetPlayer then
  41. bitePlayer(targetPlayer)
  42. end
  43. end
  44. end
  45. end
  46.  
  47. local function toggleScript()
  48. active = not active
  49. end
  50.  
  51. game:GetService("UserInputService").InputBegan:Connect(function(input)
  52. if input.KeyCode == Enum.KeyCode.P then
  53. toggleScript()
  54. end
  55. end)
  56.  
  57. startBiting()
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement