Advertisement
C-H-4-0-S

Swordbot v1

Mar 30th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local humanoid = player.Character.Humanoid
  3. local userInputService = game:GetService("UserInputService")
  4. local isEnabled = false
  5. local scriptURL = "https://raw.githubusercontent.com/78n/Amity/main/KillAura.lua"
  6. local scriptInstance = nil
  7. local maxDistance = 30
  8. local originalSpeed = humanoid.WalkSpeed
  9. local newSpeed = 19
  10.  
  11. local function findClosestPlayer()
  12. local closestDistance = maxDistance
  13. local closestPlayer = nil
  14. for _, otherPlayer in pairs(game.Players:GetPlayers()) do
  15. if otherPlayer ~= player then
  16. local character = otherPlayer.Character
  17. if character and character:FindFirstChild("HumanoidRootPart") then
  18. local distance = (character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude
  19. if distance < closestDistance then
  20. closestDistance = distance
  21. closestPlayer = otherPlayer
  22. end
  23. end
  24. end
  25. end
  26. return closestPlayer
  27. end
  28.  
  29. local function followTarget()
  30. local target = findClosestPlayer()
  31. if target then
  32. humanoid:MoveTo(target.Character.HumanoidRootPart.Position)
  33. end
  34. end
  35.  
  36. local function enableScript()
  37. isEnabled = true
  38. humanoid.WalkSpeed = newSpeed
  39. followTarget()
  40. scriptInstance = loadstring(game:HttpGetAsync(scriptURL))
  41. scriptInstance()
  42. end
  43.  
  44. local function disableScript()
  45. isEnabled = false
  46. humanoid.WalkSpeed = originalSpeed
  47. humanoid:MoveTo(player.Character.HumanoidRootPart.Position)
  48. if scriptInstance then
  49. scriptInstance = nil
  50. end
  51. end
  52.  
  53. local function onCharacterAdded(character)
  54. local target = findClosestPlayer()
  55. if target then
  56. target.CharacterAdded:Connect(function(char)
  57. char.Humanoid.Jumping:Connect(function()
  58. humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
  59. end)
  60. end)
  61. end
  62. end
  63.  
  64. player.CharacterAdded:Connect(onCharacterAdded)
  65.  
  66. userInputService.InputBegan:Connect(function(input)
  67. if input.KeyCode == Enum.KeyCode.X then
  68. if isEnabled then
  69. disableScript()
  70. else
  71. enableScript()
  72. end
  73. end
  74. end)
  75.  
  76. while true do
  77. if isEnabled then
  78. followTarget()
  79. end
  80. wait(0)
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement