Advertisement
eruaaaaaaa

test build

Sep 9th, 2022 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.66 KB | None | 0 0
  1. local Aimbot = {}
  2. Aimbot.__index = Aimbot
  3.  
  4. --//Localization
  5. local Instance = Instance
  6. local game = game
  7. local math = math
  8. local setmetatable = setmetatable
  9. local workspace = workspace
  10. local CFrame = CFrame
  11. local Vector3 = Vector3
  12. local Vector2 = Vector2
  13. local Random = Random
  14. local RaycastParams = RaycastParams
  15. local pairs = pairs
  16. local task = task
  17. local string = string
  18. local table = table
  19. local require = require
  20. local Enum = Enum
  21. local getrawmetatable = getrawmetatable
  22. local replaceclosure = replaceclosure
  23. local setreadonly = setreadonly
  24. local checkcaller = checkcaller
  25. local getclock = os.clock
  26. local mouse1press = mouse1press
  27. local mouse1release = mouse1release
  28. local mousemoverel = mousemoverel
  29. local hookfunction = hookfunction
  30. local newcclosure = newcclosure
  31.  
  32. --//Instance methods
  33. local Raycast = workspace.Raycast
  34. local GetPropertyChangedSignal = game.GetPropertyChangedSignal
  35. local Connect = game.ChildAdded.Connect
  36. local Destroy = game.Destroy
  37. local GetService = game.GetService
  38. local FindFirstChildOfClass = game.FindFirstChildOfClass
  39. local FindFirstChild = game.FindFirstChild
  40. local WaitForChild = game.WaitForChild
  41. local GetChildren = game.GetChildren
  42. local GetDescendants = game.GetDescendants
  43. local IsA = game.IsA
  44. local IsDescendantOf = game.IsDescendantOf
  45.  
  46. --//Services
  47. local Players = GetService(game, "Players")
  48. local UserInputService = GetService(game, "UserInputService")
  49. local RunService = GetService(game, "RunService")
  50. local GuiService = GetService(game, "GuiService")
  51.  
  52. --//Temporary instances
  53. local tempcam = Instance.new("Camera")
  54. local temphum = Instance.new("Humanoid")
  55. local tempconn = Connect(game.AncestryChanged, function() end)
  56.  
  57. --//Other instance methods
  58. local WorldToViewportPoint = tempcam.WorldToViewportPoint
  59. local WorldToScreenPoint = tempcam.WorldToScreenPoint
  60. local GetPlayers = Players.GetPlayers
  61. local GetPlayerFromCharacter = Players.GetPlayerFromCharacter
  62. local GetMouseLocation = UserInputService.GetMouseLocation
  63. local ViewportPointToRay = tempcam.ViewportPointToRay
  64. local ScreenPointToRay = tempcam.ScreenPointToRay
  65. local GetGuiInset = GuiService.GetGuiInset
  66. local Disconnect = tempconn.Disconnect
  67. local MoveTo = temphum.MoveTo
  68. local Lerp2D = Vector2.new().Lerp
  69.  
  70.  
  71.  
  72. --//Cleanup
  73. Destroy(temphum)
  74. Destroy(tempcam)
  75. Disconnect(tempconn)
  76.  
  77. --//Local functions and constant variables
  78.  
  79. Aimbot.DefaultSettings = {
  80. Tracking = {
  81. RadiusPercentAt1 = 145,
  82. RadiusCap = 300,
  83. XSmoothingPercent = 1,
  84. YSmoothingPercent = 1,
  85. };
  86.  
  87. Flicking = {
  88. RadiusPercentAt1 = 145,
  89. RadiusCap = 300,
  90. XSmoothingPercent = 1,
  91. YSmoothingPercent = 1,
  92. };
  93.  
  94. SilentAim = {
  95. RadiusPercentAt1 = 145,
  96. };
  97.  
  98. Deadzone = {
  99. Enabled = false,
  100. XSmoothingPercent = .5,
  101. YSmoothingPercent = .5,
  102. };
  103.  
  104. Checks = {
  105. Size = true,
  106. Invisible = true,
  107. Team = true,
  108. Wall = {
  109. TransparencyThreshold = .4, -- 0 would disable Wallcheck
  110. DefaultIgnore = {},
  111. };
  112. };
  113.  
  114. Other = {
  115. DistanceBias = 1.4,
  116. Offset = Vector2.new(0, 0)
  117. }
  118. }
  119.  
  120. Aimbot.Targets = setmetatable({}, {__index = function(a, b)
  121. a[b] = false; return false
  122. end})
  123.  
  124. -- Main
  125. local LocalPlayer = Players.LocalPlayer
  126. local Mouse = LocalPlayer.GetMouse(LocalPlayer)
  127.  
  128. local function OnCameraChange()
  129. local cam = workspace.CurrentCamera
  130.  
  131. Aimbot.Camera = cam
  132. Aimbot.ViewportSize = cam.ViewportSize
  133. Aimbot.WidthFactor = cam.ViewportSize.X / 100
  134. end
  135.  
  136. local function UpdateTable(tab, update)
  137. for name, value in pairs(update) do
  138. if tab[name] == nil then
  139. tab[name] = value
  140. end
  141. end
  142. end
  143.  
  144. local function GetChildrenWhichIsA(part, baseclass)
  145. local parts = GetChildren(part)
  146. local len = #parts
  147.  
  148. local filtered = {}
  149.  
  150. if len > 0 then
  151. for i = 1, len do
  152. local p = parts[i]
  153.  
  154. if IsA(p, baseclass) then
  155. table.insert(filtered, p)
  156. end
  157. end
  158. end
  159.  
  160. return filtered
  161. end
  162.  
  163. local function GetDescendantsWhichIsA(part, baseclass)
  164. local parts = GetDescendants(part)
  165. local len = #parts
  166.  
  167. local filtered = {}
  168.  
  169. if len > 0 then
  170. for i = 1, len do
  171. local p = parts[i]
  172.  
  173. if IsA(p, baseclass) then
  174. table.insert(filtered, p)
  175. end
  176. end
  177. end
  178.  
  179. return filtered
  180. end
  181.  
  182. local function GetChildrenWhichIsNotA(part, baseclass)
  183. local parts = GetChildren(part)
  184. local len = #parts
  185.  
  186. local filtered = {}
  187.  
  188. if len > 0 then
  189. for i = 1, len do
  190. local p = parts[i]
  191.  
  192. if not IsA(p, baseclass) then
  193. table.insert(filtered, p)
  194. end
  195. end
  196. end
  197.  
  198. return filtered
  199. end
  200.  
  201. if workspace.CurrentCamera then
  202. OnCameraChange()
  203. end
  204.  
  205. Connect(GetPropertyChangedSignal(workspace, "CurrentCamera"), OnCameraChange)
  206.  
  207. --//Methods
  208.  
  209. function Aimbot:GetBiasAtDistance(distance)
  210. if self.Camera then
  211. return distance * self.Other.DistanceBias * self.WidthFactor
  212. end
  213. end
  214.  
  215. function Aimbot:GetRadiusAtDistance(rpercent, distance)
  216. if self.Camera then
  217. if rpercent == self.Tracking.RadiusPercentAt1 and distance >= self.Tracking.RadiusCap then
  218. distance = self.Tracking.RadiusCap
  219. elseif rpercent == self.Flicking.RadiusPercentAt1 and distance >= self.Flicking.RadiusCap then
  220. distance = self.Flicking.RadiusCap
  221. end
  222.  
  223. if rpercent ~= self.SilentAim.RadiusPercentAt1 and self.Visuals.FOV then
  224. self:DrawFOV(rpercent / distance * self.WidthFactor)
  225. end
  226.  
  227. return rpercent / distance * self.WidthFactor
  228. end
  229. end
  230.  
  231. function Aimbot:GetBlockingPart(origin, position, ignore)
  232. self.WallCheckParams.FilterDescendantsInstances = self.Checks.Wall.DefaultIgnore
  233.  
  234. local direction = position - origin
  235. local thisignore = self.WallCheckParams.FilterDescendantsInstances
  236.  
  237. if ignore then
  238. table.move(ignore, 1, #ignore, #thisignore + 1, thisignore)
  239. end
  240.  
  241. while true do
  242. self.WallCheckParams.FilterDescendantsInstances = thisignore
  243.  
  244. local result = Raycast(workspace, origin, direction, self.WallCheckParams)
  245.  
  246. if result then
  247. if result.Instance.ClassName ~= "Terrain" and result.Instance.Transparency >= self.Checks.Wall.TransparencyThreshold then
  248. table.insert(thisignore, result.Instance)
  249. continue
  250. end
  251.  
  252. self.WallCheckParams.FilterDescendantsInstances = self.Checks.Wall.DefaultIgnore
  253. return result.Instance, (result.Position - result.Instance.Position).Magnitude
  254. end
  255.  
  256. self.WallCheckParams.FilterDescendantsInstances = self.Checks.Wall.DefaultIgnore
  257. return nil
  258. end
  259. end
  260.  
  261. function Aimbot:GetTargetFromViewportPoint(point, distance, ignore)
  262. local camera, ray = self.Camera, nil
  263.  
  264. if camera then
  265. local ray = ViewportPointToRay(camera, point.X, point.Y)
  266. return self:GetBlockingPart(ray.Origin, ray.Origin + ray.Direction * distance, ignore)
  267. end
  268. end
  269.  
  270. function Aimbot:GetClosestEdgeFromViewportPoint(point, part)
  271. local camera = self.Camera
  272.  
  273. if camera then
  274. local ray = ViewportPointToRay(camera, point.X, point.Y)
  275. local partposition = part.Position
  276.  
  277. local distance = (ray.Origin - partposition).Magnitude
  278. local direction = (ray.Origin + ray.Direction * distance - partposition).Unit
  279.  
  280. local size = part.Size
  281. local half = size / 2
  282. local final = direction * size
  283.  
  284. return partposition + Vector3.new(
  285. final.X < 0 and math.max(final.X, -half.X + size.X / 10) or math.min(final.X, half.X - size.X / 10),
  286. final.Y < 0 and math.max(final.Y, -half.Y + size.Y / 10) or math.min(final.Y, half.Y - size.Y / 10),
  287. final.Z < 0 and math.max(final.Z, -half.Z + size.Z / 10) or math.min(final.Z, half.Z - size.Z / 10)
  288. )
  289. end
  290. end
  291.  
  292. function Aimbot:GetMouseViewportPoint()
  293. return GetMouseLocation(UserInputService) + self.Other.Offset
  294. end
  295.  
  296. function Aimbot:GetBestPartFromViewportPoint(position, parts, ignoreparent, ignore)
  297. local camera = self.Camera
  298.  
  299. if camera then
  300. local length = #parts
  301.  
  302. if length > 0 then
  303. local leastbias, leastworlddistance, leastpixeldistance, part = math.huge, math.huge, math.huge, nil
  304. local cameraposition = camera.CFrame.Position
  305.  
  306. ignore = ignore or {}
  307. local ipos = #ignore + 1
  308.  
  309. for i = 1, length do
  310. local cpart = parts[i]
  311. local cpos = cpart.Position
  312.  
  313. local point, onscreen = WorldToViewportPoint(camera, cpos)
  314. ignore[ipos] = ignoreparent and cpart.Parent or cpart
  315.  
  316. if onscreen and not self:GetBlockingPart(cameraposition, cpos, ignore) then
  317. local playerobject = GetPlayerFromCharacter(Players, cpart.Parent)
  318.  
  319. local pixeldistance = (position - Vector2.new(point.X, point.Y)).Magnitude
  320. local worlddistance = (cameraposition - cpos).Magnitude
  321.  
  322. if playerobject then
  323. local radius = self.Targets[playerobject] and self.Tracking.RadiusPercentAt1 or self.Flicking.RadiusPercentAt1
  324.  
  325. if pixeldistance <= self:GetRadiusAtDistance(radius, worlddistance) then
  326. local bias = self:GetBiasAtDistance(worlddistance) + pixeldistance
  327.  
  328. if bias < leastbias or (bias == leastbias and worlddistance < leastworlddistance) then
  329. leastbias = bias
  330. leastworlddistance = worlddistance
  331. leastpixeldistance = pixeldistance
  332. part = cpart
  333. end
  334. end
  335. end
  336. end
  337. end
  338.  
  339. ignore[ipos] = nil
  340. return part, part and leastpixeldistance <= self:GetRadiusAtDistance(self.SilentAim.RadiusPercentAt1, leastworlddistance)
  341. end
  342. end
  343. end
  344.  
  345. function Aimbot:GetBestPlayerTargetFromViewportPoint(pos)
  346. local camera = self.Camera
  347.  
  348. if camera then
  349. local plrs = GetPlayers(Players)
  350. local length = #plrs
  351.  
  352. if length > 0 then
  353. local maxPlr = {}
  354. local parts = {}
  355. local lparts = 1
  356.  
  357. for i = 1, length do
  358. local plr = plrs[i]
  359. local charac = plr.Character
  360.  
  361. if plr ~= LocalPlayer and charac then
  362. if self.Checks.Team and not plr.Neutral and plr.Team == LocalPlayer.Team then
  363. continue
  364. end
  365.  
  366. if self.Checks.Invisible then
  367. local head = FindFirstChild(charac, "Head")
  368.  
  369. if not head or head.Transparency >= 1 then
  370. continue
  371. end
  372. end
  373.  
  374. if self.Checks.Size then
  375. local root = FindFirstChild(charac, "HumanoidRootPart")
  376.  
  377. if not root or root.Size.X < 2 or root.Size.Y < 2 or root.Size.Z < 1 then
  378. continue
  379. end
  380. end
  381.  
  382. local humanoid = FindFirstChildOfClass(charac, "Humanoid")
  383.  
  384. if not humanoid or humanoid.Health <= 0 then
  385. continue
  386. end
  387.  
  388. local filtered = GetChildrenWhichIsA(charac, "BasePart")
  389. local lfiltered = #filtered
  390.  
  391. table.move(filtered, 1, lfiltered, lparts, parts)
  392. lparts = lparts + lfiltered
  393. end
  394. end
  395.  
  396. local target, silent = self:GetBestPartFromViewportPoint(pos, parts, false) -- true
  397. local playerobject = target and GetPlayerFromCharacter(Players, target.Parent)
  398.  
  399. for player, _ in pairs(self.Targets) do
  400. if player ~= playerobject then
  401. self.Targets[player] = false
  402. end
  403. end
  404.  
  405. if target then
  406. return target, silent
  407. end
  408. end
  409. end
  410. end
  411.  
  412. Aimbot.FOVDrawing = Drawing.new("Circle")
  413. Aimbot.TracerDrawing = Drawing.new("Line")
  414.  
  415. function Aimbot:DrawFOV(radius)
  416. if not self.Visuals.FOV then self.FOVDrawing.Visible = false end
  417. self.FOVDrawing.Visible = true
  418. self.FOVDrawing.Thickness = 2
  419. self.FOVDrawing.NumSides = 12
  420. self.FOVDrawing.Radius = radius
  421. self.FOVDrawing.Filled = false
  422. self.FOVDrawing.Position = self:GetMouseViewportPoint()
  423. end
  424.  
  425. function Aimbot:DrawTracer(rel)
  426. if self.Visuals.Tracer then
  427. if rel then
  428. self.TracerDrawing.Color = Color3.fromRGB(255, 0, 0)
  429. self.TracerDrawing.Thickness = 1
  430. self.TracerDrawing.From = self:GetMouseViewportPoint()
  431. self.TracerDrawing.To = rel
  432. self.TracerDrawing.Visible = true
  433. else
  434. self.TracerDrawing.Visible = false
  435. end
  436. else
  437. self.TracerDrawing.Visible = false
  438. end
  439. end
  440.  
  441. function Aimbot:Start()
  442. self.Enabled = true
  443. local relative, fdelta, x = nil, 0.016666666666666666, nil
  444.  
  445. if not self.RenderStep then
  446. local last = 0
  447.  
  448. self.RenderStep = Connect(RunService.RenderStepped, function(delta)
  449. local ltime = tick()
  450.  
  451. if ltime > last + fdelta or (1 / delta < 60) then
  452. last = ltime
  453.  
  454. if self.Enabled and relative then
  455. Aimbot.FOVDrawing.Color = Color3.fromRGB(0, 255, 0)
  456.  
  457. self:DrawTracer(Vector2.new(x.X, x.Y))
  458. mousemoverel(relative.X, relative.Y)
  459. else
  460. Aimbot.FOVDrawing.Color = Color3.fromRGB(255, 0, 0)
  461. self:DrawTracer()
  462. end
  463. end
  464. end)
  465. end
  466.  
  467. if not self.Heartbeat then
  468. local last = 0
  469.  
  470. self.Heartbeat = Connect(RunService.Heartbeat, function(delta)
  471. local ltime = tick()
  472.  
  473. if ltime > last + fdelta or (1 / delta < 60) then
  474. last = ltime
  475. relative = nil
  476.  
  477. if self.Enabled then
  478. local camera = self.Camera
  479.  
  480. if camera then
  481. local mpos = self:GetMouseViewportPoint()
  482. local target, silent = self:GetBestPlayerTargetFromViewportPoint(mpos)
  483.  
  484. if target then
  485. local charac = target.Parent
  486. local playerobject = GetPlayerFromCharacter(Players, charac)
  487. local cignore = GetChildrenWhichIsNotA(charac, "BasePart")
  488.  
  489. local lcharac = LocalPlayer.Character
  490. table.insert(cignore, lcharac)
  491.  
  492. local mtarget = self:GetTargetFromViewportPoint(mpos, 5000, {lcharac})
  493.  
  494. if mtarget and IsDescendantOf(mtarget, charac) then
  495. self.mspoof = nil
  496. self.Targets[playerobject] = true
  497. else
  498.  
  499. if silent then
  500. self.mspoof = self:GetClosestEdgeFromViewportPoint(mpos, target)
  501. else
  502. self.mspoof = nil
  503. end
  504. end
  505.  
  506. if self.Targets[playerobject] then
  507.  
  508. if self.Deadzone.Enabled then
  509. local pos, onscreen = WorldToViewportPoint(camera, target.Position)
  510.  
  511. if onscreen then
  512. local g = (Vector2.new(pos.X, pos.Y) - mpos) / Vector2.new(self.Deadzone.XSmoothingPercent * self.WidthFactor, self.Deadzone.YSmoothingPercent * self.WidthFactor)
  513. mousemoverel(g.X, g.Y)
  514. end
  515. end
  516. end
  517.  
  518. local pos, onscreen = WorldToViewportPoint(camera, target.Position)
  519. x = pos
  520.  
  521. print(mtarget)
  522.  
  523. if onscreen then
  524.  
  525. if not (mtarget and IsDescendantOf(mtarget, charac)) then
  526.  
  527. if self.Targets[playerobject] then
  528. local displ = (Vector2.new(pos.X, pos.Y) - mpos)
  529. local rel = Vector2.new(displ.X, displ.Y) / Vector2.new(self.Tracking.XSmoothingPercent * self.WidthFactor, self.Tracking.YSmoothingPercent * self.WidthFactor)
  530.  
  531. local rX = (displ.X >= 1 and rel.X < 1) and 1 or rel.X
  532. local rY = (displ.Y >= 1 and rel.Y < 1) and 1 or rel.Y
  533.  
  534. relative = Vector2.new(rX, rY)
  535. else
  536. local displ = (Vector2.new(pos.X, pos.Y) - mpos)
  537. local rel = Vector2.new(displ.X, displ.Y) / Vector2.new(self.Flicking.XSmoothingPercent * self.WidthFactor, self.Flicking.YSmoothingPercent * self.WidthFactor)
  538.  
  539. local rX = (displ.X >= 1 and rel.X < 1) and 1 or rel.X
  540. local rY = (displ.Y >= 1 and rel.Y < 1) and 1 or rel.Y
  541.  
  542. relative = Vector2.new(rX, rY)
  543. end
  544. end
  545. end
  546. end
  547. end
  548. end
  549. end
  550. end)
  551. end
  552. end
  553.  
  554. function Aimbot.new(presets)
  555. presets = presets or {}
  556. UpdateTable(presets, Aimbot.DefaultSettings)
  557.  
  558. local WallCheckParams = RaycastParams.new()
  559. WallCheckParams.FilterType = Enum.RaycastFilterType.Blacklist
  560. WallCheckParams.IgnoreWater = true
  561. WallCheckParams.FilterDescendantsInstances = presets.Checks.Wall.DefaultIgnore
  562.  
  563. presets.WallCheckParams = WallCheckParams
  564. return setmetatable(presets, Aimbot)
  565. end
  566.  
  567. return Aimbot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement