Advertisement
Jack12332

aimbot

Apr 21st, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.02 KB | None | 0 0
  1. --// Cache
  2.  
  3. local select = select
  4. local pcall, getgenv, next, Vector2, mathclamp, type, mousemoverel = select(1, pcall, getgenv, next, Vector2.new, math.clamp, type, mousemoverel or (Input and Input.MouseMove))
  5.  
  6. --// Preventing Multiple Processes
  7.  
  8. pcall(function()
  9. getgenv().Aimbot.Functions:Exit()
  10. end)
  11.  
  12. --// Environment
  13.  
  14. getgenv().Aimbot = {}
  15. local Environment = getgenv().Aimbot
  16.  
  17. --// Services
  18.  
  19. local RunService = game:GetService("RunService")
  20. local UserInputService = game:GetService("UserInputService")
  21. local TweenService = game:GetService("TweenService")
  22. local Players = game:GetService("Players")
  23. local Camera = workspace.CurrentCamera
  24. local LocalPlayer = Players.LocalPlayer
  25.  
  26. --// Variables
  27.  
  28. local RequiredDistance, Typing, Running, Animation, ServiceConnections = 2000, false, false, nil, {}
  29.  
  30. --// Script Settings
  31.  
  32. Environment.Settings = {
  33. Enabled = true,
  34. TeamCheck = false,
  35. AliveCheck = true,
  36. WallCheck = false, -- Laggy
  37. Sensitivity = 0, -- Animation length (in seconds) before fully locking onto target
  38. ThirdPerson = false, -- Uses mousemoverel instead of CFrame to support locking in third person (could be choppy)
  39. ThirdPersonSensitivity = 3, -- Boundary: 0.1 - 5
  40. TriggerKey = "E",
  41. Toggle = false,
  42. LockPart = "Head" -- Body part to lock on
  43. }
  44.  
  45. Environment.FOVSettings = {
  46. Enabled = true,
  47. Visible = true,
  48. Amount = 90,
  49. Color = Color3.fromRGB(255, 255, 255),
  50. LockedColor = Color3.fromRGB(255, 70, 70),
  51. Transparency = 0.5,
  52. Sides = 60,
  53. Thickness = 1,
  54. Filled = false
  55. }
  56.  
  57. Environment.FOVCircle = Drawing.new("Circle")
  58.  
  59. --// Functions
  60.  
  61. local function CancelLock()
  62. Environment.Locked = nil
  63. if Animation then Animation:Cancel() end
  64. Environment.FOVCircle.Color = Environment.FOVSettings.Color
  65. end
  66.  
  67. local function GetClosestPlayer()
  68. if not Environment.Locked then
  69. RequiredDistance = (Environment.FOVSettings.Enabled and Environment.FOVSettings.Amount or 2000)
  70.  
  71. for _, v in next, Players:GetPlayers() do
  72. if v ~= LocalPlayer then
  73. if v.Character and v.Character:FindFirstChild(Environment.Settings.LockPart) and v.Character:FindFirstChildOfClass("Humanoid") then
  74. if Environment.Settings.TeamCheck and v.Team == LocalPlayer.Team then continue end
  75. if Environment.Settings.AliveCheck and v.Character:FindFirstChildOfClass("Humanoid").Health <= 0 then continue end
  76. if Environment.Settings.WallCheck and #(Camera:GetPartsObscuringTarget({v.Character[Environment.Settings.LockPart].Position}, v.Character:GetDescendants())) > 0 then continue end
  77.  
  78. local Vector, OnScreen = Camera:WorldToViewportPoint(v.Character[Environment.Settings.LockPart].Position)
  79. local Distance = (Vector2(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y) - Vector2(Vector.X, Vector.Y)).Magnitude
  80.  
  81. if Distance < RequiredDistance and OnScreen then
  82. RequiredDistance = Distance
  83. Environment.Locked = v
  84. end
  85. end
  86. end
  87. end
  88. elseif (Vector2(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y) - Vector2(Camera:WorldToViewportPoint(Environment.Locked.Character[Environment.Settings.LockPart].Position).X, Camera:WorldToViewportPoint(Environment.Locked.Character[Environment.Settings.LockPart].Position).Y)).Magnitude > RequiredDistance then
  89. CancelLock()
  90. end
  91. end
  92.  
  93. --// Typing Check
  94.  
  95. ServiceConnections.TypingStartedConnection = UserInputService.TextBoxFocused:Connect(function()
  96. Typing = true
  97. end)
  98.  
  99. ServiceConnections.TypingEndedConnection = UserInputService.TextBoxFocusReleased:Connect(function()
  100. Typing = false
  101. end)
  102.  
  103. --// Main
  104.  
  105. local function Load()
  106. ServiceConnections.RenderSteppedConnection = RunService.RenderStepped:Connect(function()
  107. if Environment.FOVSettings.Enabled and Environment.Settings.Enabled then
  108. Environment.FOVCircle.Radius = Environment.FOVSettings.Amount
  109. Environment.FOVCircle.Thickness = Environment.FOVSettings.Thickness
  110. Environment.FOVCircle.Filled = Environment.FOVSettings.Filled
  111. Environment.FOVCircle.NumSides = Environment.FOVSettings.Sides
  112. Environment.FOVCircle.Color = Environment.FOVSettings.Color
  113. Environment.FOVCircle.Transparency = Environment.FOVSettings.Transparency
  114. Environment.FOVCircle.Visible = Environment.FOVSettings.Visible
  115. Environment.FOVCircle.Position = Vector2(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y)
  116. else
  117. Environment.FOVCircle.Visible = false
  118. end
  119.  
  120. if Running and Environment.Settings.Enabled then
  121. GetClosestPlayer()
  122.  
  123. if Environment.Locked then
  124. if Environment.Settings.ThirdPerson then
  125. Environment.Settings.ThirdPersonSensitivity = mathclamp(Environment.Settings.ThirdPersonSensitivity, 0.1, 5)
  126.  
  127. local Vector = Camera:WorldToViewportPoint(Environment.Locked.Character[Environment.Settings.LockPart].Position)
  128. mousemoverel((Vector.X - UserInputService:GetMouseLocation().X) * Environment.Settings.ThirdPersonSensitivity, (Vector.Y - UserInputService:GetMouseLocation().Y) * Environment.Settings.ThirdPersonSensitivity)
  129. else
  130. if Environment.Settings.Sensitivity > 0 then
  131. Animation = TweenService:Create(Camera, TweenInfo.new(Environment.Settings.Sensitivity, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = CFrame.new(Camera.CFrame.Position, Environment.Locked.Character[Environment.Settings.LockPart].Position)})
  132. Animation:Play()
  133. else
  134. Camera.CFrame = CFrame.new(Camera.CFrame.Position, Environment.Locked.Character[Environment.Settings.LockPart].Position)
  135. end
  136. end
  137.  
  138. Environment.FOVCircle.Color = Environment.FOVSettings.LockedColor
  139.  
  140. end
  141. end
  142. end)
  143.  
  144. ServiceConnections.InputBeganConnection = UserInputService.InputBegan:Connect(function(Input)
  145. if not Typing then
  146. pcall(function()
  147. if Input.KeyCode == Enum.KeyCode[Environment.Settings.TriggerKey] then
  148. if Environment.Settings.Toggle then
  149. Running = not Running
  150.  
  151. if not Running then
  152. CancelLock()
  153. end
  154. else
  155. Running = true
  156. end
  157. end
  158. end)
  159.  
  160. pcall(function()
  161. if Input.UserInputType == Enum.UserInputType[Environment.Settings.TriggerKey] then
  162. if Environment.Settings.Toggle then
  163. Running = not Running
  164.  
  165. if not Running then
  166. CancelLock()
  167. end
  168. else
  169. Running = true
  170. end
  171. end
  172. end)
  173. end
  174. end)
  175.  
  176. ServiceConnections.InputEndedConnection = UserInputService.InputEnded:Connect(function(Input)
  177. if not Typing then
  178. if not Environment.Settings.Toggle then
  179. pcall(function()
  180. if Input.KeyCode == Enum.KeyCode[Environment.Settings.TriggerKey] then
  181. Running = false; CancelLock()
  182. end
  183. end)
  184.  
  185. pcall(function()
  186. if Input.UserInputType == Enum.UserInputType[Environment.Settings.TriggerKey] then
  187. Running = false; CancelLock()
  188. end
  189. end)
  190. end
  191. end
  192. end)
  193. end
  194.  
  195. --// Functions
  196.  
  197. Environment.Functions = {}
  198.  
  199. function Environment.Functions:Exit()
  200. for _, v in next, ServiceConnections do
  201. v:Disconnect()
  202. end
  203.  
  204. if Environment.FOVCircle.Remove then Environment.FOVCircle:Remove() end
  205.  
  206. getgenv().Aimbot.Functions = nil
  207. getgenv().Aimbot = nil
  208.  
  209. Load = nil; GetClosestPlayer = nil; CancelLock = nil
  210. end
  211.  
  212. function Environment.Functions:Restart()
  213. for _, v in next, ServiceConnections do
  214. v:Disconnect()
  215. end
  216.  
  217. Load()
  218. end
  219.  
  220. function Environment.Functions:ResetSettings()
  221. Environment.Settings = {
  222. Enabled = true,
  223. TeamCheck = false,
  224. AliveCheck = true,
  225. WallCheck = false,
  226. Sensitivity = 0, -- Animation length (in seconds) before fully locking onto target
  227. ThirdPerson = false, -- Uses mousemoverel instead of CFrame to support locking in third person (could be choppy)
  228. ThirdPersonSensitivity = 3, -- Boundary: 0.1 - 5
  229. TriggerKey = "MouseButton2",
  230. Toggle = false,
  231. LockPart = "Head" -- Body part to lock on
  232. }
  233.  
  234. Environment.FOVSettings = {
  235. Enabled = true,
  236. Visible = true,
  237. Amount = 90,
  238. Color = Color3.fromRGB(255, 255, 255),
  239. LockedColor = Color3.fromRGB(255, 70, 70),
  240. Transparency = 0.5,
  241. Sides = 60,
  242. Thickness = 1,
  243. Filled = false
  244. }
  245. end
  246.  
  247. --// Load
  248.  
  249. Load()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement