janus420

we love it

Dec 18th, 2021
2,758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. -- janus, note the aimBot is toggle not hold.
  2.  
  3. -- Config --
  4.  
  5. local toggleAimBotKey = Enum.KeyCode.E
  6.  
  7. -- End of Config --
  8. local userInputService = game:GetService("UserInputService")
  9. local player = game.Players.LocalPlayer
  10. local runService = game:GetService("RunService")
  11. local players = {}
  12. local aimBotEnabled = false
  13. local Camera = game.Workspace.CurrentCamera
  14. local connection = nil
  15. local aimBotTarget = nil
  16. local mouse = player:GetMouse()
  17.  
  18. local function getTargetPlayer()
  19. local smallestMag = 9999
  20. local closestPlayer
  21. local mousePos = Vector2.new(userInputService:GetMouseLocation().x, userInputService:GetMouseLocation().y)
  22. for i,v in pairs(game.Players:GetPlayers()) do
  23. if (v ~= player) then
  24. if (v.Character ~= nil) then
  25. if (v.Character:FindFirstChild("Humanoid") ~= nil) then
  26. if (v.Character:FindFirstChild("Humanoid").Health ~= 0) then
  27. local targetPlayerPos = Camera:WorldToScreenPoint(v.Character:WaitForChild("HumanoidRootPart", math.huge).Position)
  28. if (targetPlayerPos.Z > 0) then
  29. local targetPlayerVec2 = Vector2.new(targetPlayerPos.X, targetPlayerPos.Y)
  30. local mag = (targetPlayerVec2 - mousePos).Magnitude
  31. if (mag < smallestMag) then
  32. smallestMag = mag
  33. closestPlayer = v
  34. end
  35. end
  36. else
  37. Camera.CameraType = Enum.CameraType.Custom
  38. Camera.CameraType = Enum.CameraType.Scriptable
  39. end
  40. end
  41. end
  42. end
  43. end
  44. aimBotTarget = closestPlayer.Character:FindFirstChild("Head")
  45. end
  46.  
  47. userInputService.InputBegan:Connect(function(inputObject)
  48. if (inputObject.KeyCode == toggleAimBotKey) then
  49. if (aimBotEnabled) then
  50. aimBotEnabled = false
  51. hasTarget = false
  52. Camera.CameraType = Enum.CameraType.Custom
  53. else
  54. aimBotEnabled = true
  55. Camera.CameraType = Enum.CameraType.Scriptable
  56. end
  57. end
  58. end)
  59.  
  60. connection = runService.Heartbeat:Connect(function()
  61. if (aimBotEnabled) then
  62. getTargetPlayer()
  63. if (aimBotTarget ~= nil) then
  64. Camera.CameraType = Enum.CameraType.Scriptable
  65. Camera.CFrame = CFrame.new(player.Character.Head.Position, aimBotTarget.position)
  66. else
  67. hasTarget = false
  68. Camera.CameraType = Enum.CameraType.Custom
  69. end
  70. end
  71. if (player.Character:FindFirstChild("Humanoid").Health == 0) then
  72. aimBotEnabled = false
  73. hasTarget = false
  74. Camera.CameraType = Enum.CameraType.Custom
  75. end
  76. end)
  77.  
  78.  
Advertisement
Add Comment
Please, Sign In to add comment