Advertisement
eruaaaaaaa

testbuild

Apr 26th, 2022 (edited)
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.08 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 string = string
  17. local table = table
  18. local Enum = Enum
  19. local getrawmetatable = getrawmetatable
  20. local replaceclosure = replaceclosure
  21. local setreadonly = setreadonly
  22. local checkcaller = checkcaller
  23. local getclock = os.clock
  24. local mouse1press = mouse1press
  25. local mouse1release = mouse1release
  26. local mousemoverel = mousemoverel
  27. local hookfunction = hookfunction
  28. local newcclosure = newcclosure
  29.  
  30. --//Instance methods
  31. local Raycast = workspace.Raycast
  32. local GetPropertyChangedSignal = game.GetPropertyChangedSignal
  33. local Connect = game.ChildAdded.Connect
  34. local Destroy = game.Destroy
  35. local GetService = game.GetService
  36. local FindFirstChildOfClass = game.FindFirstChildOfClass
  37. local FindFirstChild = game.FindFirstChild
  38. local GetChildren = game.GetChildren
  39. local IsA = game.IsA
  40. local IsDescendantOf = game.IsDescendantOf
  41.  
  42. --//Services
  43. local Players = GetService(game, "Players")
  44. local UserInputService = GetService(game, "UserInputService")
  45. local RunService = GetService(game, "RunService")
  46. local GuiService = GetService(game, "GuiService")
  47.  
  48. --//Temporary instances
  49. local tempcam = Instance.new("Camera")
  50. local tempconn = Connect(game.AncestryChanged, function() end)
  51.  
  52. --//Other instance methods
  53. local WorldToViewportPoint = tempcam.WorldToViewportPoint
  54. local WorldToScreenPoint = tempcam.WorldToScreenPoint
  55. local GetPlayers = Players.GetPlayers
  56. local GetMouseLocation = UserInputService.GetMouseLocation
  57. local ViewportPointToRay = tempcam.ViewportPointToRay
  58. local Disconnect = tempconn.Disconnect
  59. local Lerp2D = Vector2.new().Lerp
  60.  
  61. --//Cleanup
  62. Destroy(tempcam)
  63. Disconnect(tempconn)
  64.  
  65. --//Local functions and constant variables
  66. Aimbot.DefaultSettings = {
  67. RadiusPercentAt1 = 130, --//Radius percent of screen width at 1 stud for aimbot
  68. XSmoothingPercent = .125,
  69. YSmoothingPercent = .15, --//Slows down mouse movement by a percentage of screen width
  70. DistanceBias = 1, --//Raises sensitivity of distance from camera when choosing target
  71. Offset = Vector2.new(0, 0), --//Mouse offset in pixels
  72. SilentRadiusPercentAt1 = 130, --//Radius percent of screen width at 1 stud for silent aim
  73. IgnoreTransparent = true, --//Whether to ignore transparent parts above the threshold or not in wallcheck
  74. IgnoreWater = false, --//Whether to ignore water in wallcheck
  75. TransparencyThreshold = .5, --//Threshold for what transparency or greater counts as ignorable
  76. DefaultIgnore = {}, --//List for what the aimbot should ignore during wallcheck
  77. IsAliveCheck = true, --//Ignore dead players
  78. TeamCheck = true,
  79. TriggerBot = true,
  80. InvisibleCheck = true,
  81. TriggerBotTime = 160,
  82. TriggerBotSemi = false,
  83. TriggerBotTimeBetweenClick = .3,
  84. HoldControl = false,
  85. Holding = false,
  86. SizeCheck = false,
  87. FlickSettings = {
  88. FlickXSmoothingPercent = .9, -- .6
  89. FlickYSmoothingPercent = .9, -- .6
  90. Flick = true -- false if only will track
  91. },
  92. AutoPeak = {
  93. Enabled = false,
  94. PointPosition = nil -- dont chage this
  95. },
  96. RadiusCap = nil
  97. }
  98.  
  99. local LocalPlayer = Players.LocalPlayer
  100. local Mouse = LocalPlayer.GetMouse(LocalPlayer)
  101. local GuiInset = GuiService.GetGuiInset(GuiService)
  102. local GameMeta = getrawmetatable(game)
  103.  
  104. local function OnCameraChange()
  105. local cam = workspace.CurrentCamera
  106.  
  107. Aimbot.Camera = cam
  108. Aimbot.ViewportSize = cam.ViewportSize
  109. Aimbot.WidthFactor = cam.ViewportSize.X / 100
  110. end
  111.  
  112. local function UpdateTable(tab, update)
  113. for name, value in pairs(update) do
  114. if tab[name] == nil then
  115. tab[name] = value
  116. end
  117. end
  118. end
  119.  
  120. local function GetChildrenWhichIsA(part, baseclass)
  121. local parts = GetChildren(part)
  122. local len = #parts
  123.  
  124. local filtered = {}
  125.  
  126. if len > 0 then
  127. for i = 1, len do
  128. local p = parts[i]
  129.  
  130. if IsA(p, baseclass) then
  131. table.insert(filtered, p)
  132. end
  133. end
  134. end
  135.  
  136. return filtered
  137. end
  138.  
  139.  
  140. local function GetChildrenWhichIsNotA(part, baseclass)
  141. local parts = GetChildren(part)
  142. local len = #parts
  143.  
  144. local filtered = {}
  145.  
  146. if len > 0 then
  147. for i = 1, len do
  148. local p = parts[i]
  149.  
  150. if not IsA(p, baseclass) then
  151. table.insert(filtered, p)
  152. end
  153. end
  154. end
  155.  
  156. return filtered
  157. end
  158.  
  159. if workspace.CurrentCamera then
  160. OnCameraChange()
  161. end
  162.  
  163. Connect(GetPropertyChangedSignal(workspace, "CurrentCamera"), OnCameraChange)
  164.  
  165. --//Methods
  166.  
  167. --//Gets bias value at a given distance
  168. function Aimbot:GetBiasAtDistance(distance)
  169. if self.Camera then
  170. return distance * self.DistanceBias * self.WidthFactor
  171. end
  172. end
  173.  
  174. --//Gets circle radius at a given distance
  175. function Aimbot:GetRadiusAtDistance(rpercent, distance)
  176. if self.Camera then
  177. if self.RadiusCap then
  178. if distance >= self.RadiusCap and rpercent ~= self.SilentRadiusPercentAt1 then
  179. distance = self.RadiusCap
  180. end
  181. end
  182.  
  183. return rpercent / distance * self.WidthFactor
  184. end
  185. end
  186.  
  187. --//Checks for parts obscuring camera, including terrain - unlike Camera:GetPartsObscuringTarget
  188. function Aimbot:GetBlockingPart(origin, position, ignore)
  189. self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore --//Incase it got updated
  190.  
  191. local dir = position - origin
  192. local thisignore = self.WallCheckParams.FilterDescendantsInstances --//Copies table for you essentially
  193.  
  194. if ignore then
  195. table.move(ignore, 1, #ignore, #thisignore + 1, thisignore)
  196. end
  197.  
  198. while true do
  199. self.WallCheckParams.FilterDescendantsInstances = thisignore --//Copies
  200. local result = Raycast(workspace, origin, dir, self.WallCheckParams)
  201.  
  202. if result then
  203. if self.IgnoreTransparent and result.Instance.ClassName ~= "Terrain" and result.Instance.Transparency >= self.TransparencyThreshold then
  204. table.insert(thisignore, result.Instance)
  205. continue
  206. end
  207.  
  208. self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore
  209. return result.Instance
  210. end
  211.  
  212. self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore
  213. return nil
  214. end
  215. end
  216.  
  217. --//Gets target from viewport point
  218. function Aimbot:GetTargetFromViewportPoint(point, distance, ignore)
  219. local camera = self.Camera
  220.  
  221. if camera then
  222. local ray = ViewportPointToRay(camera, point.X, point.Y)
  223. return self:GetBlockingPart(ray.Origin, ray.Origin + ray.Direction * distance, ignore)
  224. end
  225. end
  226.  
  227. --//Gets closest edge on part from viewport point
  228. function Aimbot:GetClosestEdgeFromViewportPoint(point, part)
  229. local camera = self.Camera
  230.  
  231. if camera then
  232. local ray = ViewportPointToRay(camera, point.X, point.Y)
  233. local ppos = part.Position
  234.  
  235. local dist = (ray.Origin - ppos).Magnitude
  236. local dir = (ray.Origin + ray.Direction * dist - ppos).Unit
  237.  
  238. local size = part.Size
  239.  
  240. local half = size / 2
  241. local final = dir * size
  242.  
  243. return ppos + Vector3.new(
  244. final.X < 0 and math.max(final.X, -half.X + size.X / 10) or math.min(final.X, half.X - size.X / 10),
  245. final.Y < 0 and math.max(final.Y, -half.Y + size.Y / 10) or math.min(final.Y, half.Y - size.Y / 10),
  246. final.Z < 0 and math.max(final.Z, -half.Z + size.Z / 10) or math.min(final.Z, half.Z - size.Z / 10)
  247. )
  248. end
  249. end
  250.  
  251. --//Gets mouse location with offset accounted for
  252. function Aimbot:GetMouseViewportPoint()
  253. return GetMouseLocation(UserInputService) + self.Offset
  254. end
  255.  
  256. --//Gets best target from a list of parts and a viewport point, ignoreparent specifies whether to filter the entire parent
  257. function Aimbot:GetBestPartFromViewportPoint(position, parts, ignoreparent, ignore)
  258. local camera = self.Camera
  259.  
  260. if camera then
  261. local len = #parts
  262.  
  263. if len > 0 then
  264. local leastbias, leastwdist, leastpdist, part = math.huge, math.huge, math.huge, nil
  265. local campos = camera.CFrame.Position
  266.  
  267. ignore = ignore or {}
  268. local ipos = #ignore + 1
  269.  
  270. for i = 1, len do
  271. local cpart = parts[i]
  272. local cpos = cpart.Position
  273.  
  274. local point, onscreen = WorldToViewportPoint(camera, cpos)
  275. ignore[ipos] = ignoreparent and cpart.Parent or cpart
  276.  
  277. if onscreen and not self:GetBlockingPart(campos, cpos, ignore) then
  278. local pdist = (position - Vector2.new(point.X, point.Y)).Magnitude --//Pixel Distance
  279. local wdist = (campos - cpos).Magnitude --//World Distance
  280. local playerOb = cpart.Parent:FindFirstChildOfClass("Humanoid") and game:GetService("Players"):GetPlayerFromCharacter(cpart.Parent) or cpart.Parent.Parent:FindFirstChildOfClass("Humanoid") and game:GetService("Players"):GetPlayerFromCharacter(cpart.Parent.Parent)
  281.  
  282. if pdist <= self:GetRadiusAtDistance(self.Targets[playerOb] and self.RadiusPercentAt1 or self.FlickSettings.RadiusPercentAt1, wdist) then
  283. local bias = self:GetBiasAtDistance(wdist) + pdist
  284.  
  285. if bias < leastbias or (bias == leastbias and wdist < leastwdist) then
  286. leastbias = bias
  287. leastwdist = wdist
  288. leastpdist = pdist
  289. part = cpart
  290. end
  291. end
  292. end
  293. end
  294.  
  295. ignore[ipos] = nil
  296. return part, part and leastpdist <= self:GetRadiusAtDistance(self.SilentRadiusPercentAt1, leastwdist)
  297. end
  298. end
  299. end
  300.  
  301. --//Gets best player to target based on a viewport point
  302. function Aimbot:GetBestPlayerTargetFromViewportPoint(pos)
  303. if self.Camera then
  304. local plrs = GetPlayers(Players)
  305. local len = #plrs
  306.  
  307. if len > 0 then
  308. local parts = {}
  309. local lparts = 1
  310. local maxPlr = {}
  311. for i = 1, len do
  312. local plr = plrs[i]
  313. local charac = plr.Character
  314.  
  315. if plr ~= LocalPlayer and charac then
  316. if self.TeamCheck and not plr.Neutral and plr.Team == LocalPlayer.Team then
  317. continue
  318. end
  319.  
  320. if self.IsAliveCheck then
  321. local hum = FindFirstChildOfClass(charac, "Humanoid")
  322.  
  323. if not hum or hum.Health <= 0 then
  324. continue
  325. end
  326. end
  327.  
  328. if self.InvisibleCheck then
  329. local head = FindFirstChild(charac, "Head")
  330.  
  331. if not head or head.Transparency >= 1 then
  332. continue
  333. end
  334. end
  335.  
  336. if self.SizeCheck then
  337. local hum = FindFirstChild(charac, "HumanoidRootPart")
  338.  
  339. if not hum or hum.Size.X < 2 or hum.Size.Y < 2 or hum.Size.Z < 1 then
  340. continue
  341. end
  342. end
  343.  
  344. if self.AntiLag then
  345. if #maxPlr >= 4 then continue end
  346. table.insert(maxPlr, plr)
  347. end
  348.  
  349. local filtered = GetChildrenWhichIsA(charac, "BasePart")
  350. local lfiltered = #filtered
  351.  
  352. table.move(filtered, 1, lfiltered, lparts, parts)
  353. lparts = lparts + lfiltered
  354. end
  355. end
  356. local target, silent = self:GetBestPartFromViewportPoint(pos, parts, true)
  357. local plrz = target and game:GetService("Players"):GetPlayerFromCharacter(target.Parent) or "nil"
  358. for aa, _ in pairs(self.Targets) do
  359. if aa ~= plrz then self.Targets[aa] = false end
  360. end
  361. if target then
  362. return target, silent
  363. end
  364. end
  365. end
  366. end
  367.  
  368. --//Begins aimbot
  369.  
  370. function Aimbot:Start()
  371. self.Enabled = true
  372. self.LastTrigger = 0
  373. self.TriggerPaused = false
  374. self.Targets = {}; setmetatable(self.Targets, {__index = function(s, k)
  375. s[k] = false
  376. return false
  377. end})
  378.  
  379. local relative
  380. local holding = false
  381. local mspoof
  382.  
  383. local lastframe = getclock()
  384.  
  385. if not self.RenderStep then
  386. local totalTime = 0
  387. self.RenderStep = Connect(RunService.RenderStepped, function(delta)
  388. totalTime += delta
  389. if (totalTime < 1 / 144) then return end
  390. totalTime = 0
  391. if self.Enabled and relative then
  392. if self.HoldControl and self.Holding or not self.HoldControl then
  393. mousemoverel(relative.X, relative.Y)
  394. end
  395. end
  396. end)
  397. end
  398.  
  399. if not self.Heartbeat then
  400. local totalTime = 0
  401. self.Heartbeat = Connect(RunService.Heartbeat, function(delta)
  402. totalTime += delta
  403. if (totalTime < 1 / 144) then return end
  404. totalTime = 0
  405. relative = nil
  406.  
  407. if self.Enabled then
  408. local camera = self.Camera
  409.  
  410. if camera then
  411. local mpos = self:GetMouseViewportPoint()
  412. local target, silent = self:GetBestPlayerTargetFromViewportPoint(mpos)
  413.  
  414. if not target then
  415. if holding then
  416. holding = false
  417. mouse1release()
  418. end
  419. end
  420.  
  421. if target then
  422. local charac = target.Parent
  423. local plrz = game:GetService("Players"):GetPlayerFromCharacter(charac)
  424. local lcharac = LocalPlayer.Character
  425. local cignore = GetChildrenWhichIsNotA(charac, "BasePart")
  426.  
  427. --if cignore then
  428. table.insert(cignore, lcharac)
  429. local mtarget = self:GetTargetFromViewportPoint(mpos, 5000, cignore)
  430. local bodyPart = (FindFirstChild(lcharac, "Head") or FindFirstChild(lcharac, "HumanoidRootPart"))
  431. local BlockingParts = self:GetBlockingPart(bodyPart and bodyPart.Position, target.Position, cignore)
  432. if silent and self.TriggerBot and lcharac and BlockingParts and BlockingParts:IsDescendantOf(charac) then
  433. if not holding then
  434. holding = true
  435. mouse1press()
  436. else
  437. if self.TriggerBotSemi and (tick() - self.LastTrigger) >= self.TriggerBotTimeBetweenClick and not self.TriggerPaused then
  438. self.TriggerPaused = true
  439. task.wait(self.TriggerBotTime / 1000)
  440. mouse1press()
  441. self.LastTrigger = tick()
  442. self.TriggerPaused = false
  443. end
  444. end
  445. elseif silent and self.TriggerBot and lcharac and (not BlockingParts or not BlockingParts:IsDescendantOf(charac)) then
  446. if holding then
  447. holding = false
  448. mouse1release()
  449. end
  450. end
  451.  
  452. if mtarget and IsDescendantOf(mtarget, charac) then
  453. mspoof = nil
  454. self.Targets[plrz] = true
  455. if self.Deadzone.Enabled then
  456. target = (self.TargetPart and FindFirstChild(charac, self.TargetPart)) or target
  457. local pos, onscreen = WorldToViewportPoint(camera, target.Position)
  458. if onscreen then
  459. local g = (Vector2.new(pos.X, pos.Y) - mpos) / Vector2.new(self.Deadzone.XSmoothingPercent * self.WidthFactor, self.Deadzone.YSmoothingPercent * self.WidthFactor)
  460. mousemoverel(g.X, g.Y)
  461. end
  462. end
  463. if not self.TargetPart then
  464. return
  465. end
  466. elseif silent then
  467. mspoof = self:GetClosestEdgeFromViewportPoint(mpos, target)
  468. else
  469. mspoof = nil
  470. end
  471.  
  472. target = (self.TargetPart and FindFirstChild(charac, self.TargetPart)) or target
  473. --local pos, onscreen = WorldToViewportPoint(camera, target.Position)
  474. local pos, onscreen = WorldToViewportPoint(camera, self:GetClosestEdgeFromViewportPoint(mpos, target))
  475. if onscreen then
  476. if self.Targets[plrz] then
  477. relative = (Vector2.new(pos.X, pos.Y) - mpos) / Vector2.new(self.XSmoothingPercent * self.WidthFactor, self.YSmoothingPercent * self.WidthFactor)
  478. else
  479. relative = (Vector2.new(pos.X, pos.Y) - mpos) / Vector2.new(self.FlickSettings.FlickXSmoothingPercent * self.WidthFactor, self.FlickSettings.FlickYSmoothingPercent * self.WidthFactor)
  480. end
  481. end
  482. else
  483. if holding then
  484. holding = false
  485. mouse1release()
  486. end
  487.  
  488. mspoof = nil
  489. end
  490. else
  491. if holding then
  492. holding = false
  493. mouse1release()
  494. end
  495.  
  496. mspoof = nil
  497. end
  498. else
  499. if holding then
  500. holding = false
  501. mouse1release()
  502. end
  503.  
  504. mspoof = nil
  505. end
  506. end)
  507. end
  508. local Players2 = game.GetService(game, "Players");
  509. local Client2 = Players2.LocalPlayer;
  510. local Mouse2 = Client2.GetMouse(Client2);
  511.  
  512. local old; old = hookmetamethod(game, "__index", newcclosure(function(i,v)
  513. if string.lower(v) == "hit" then
  514. if old(i, "ClassName") == "Mouse" or old(i, "ClassName") == "PlayerMouse" then
  515. if not checkcaller() then
  516. if mspoof then
  517. return CFrame.new(mspoof)
  518. end
  519. end
  520. end
  521. end
  522. return old(i,v)
  523. end))
  524.  
  525. local old2; old2 = hookmetamethod(game, "__namecall", newcclosure(function(self2, ...)
  526. if getnamecallmethod() == "ViewportPointToRay" and not checkcaller() and mspoof then
  527. local args = {...}
  528. local pos = GetMouseLocation(UserInputService)
  529. if math.abs(args[1] - (pos.X + self.Offset.X)) <= 3 and math.abs(args[2] - (pos.Y + self.Offset.Y)) <= 3 then
  530. local newPos = workspace.CurrentCamera.WorldToViewportPoint(workspace.CurrentCamera, mspoof)
  531. args[1] = newPos.X
  532. args[2] = newPos.Y
  533. return old2(self2, table.unpack(args))
  534. else
  535. if math.abs(args[1] - (Mouse2.X + self.Offset.X)) <= 3 and math.abs(args[2] - (Mouse2.Y + self.Offset.Y)) <= 3 then
  536. local newPos = workspace.CurrentCamera.WorldToViewportPoint(workspace.CurrentCamera, mspoof)
  537. args[1] = newPos.X
  538. args[2] = newPos.Y
  539. return old2(self2, table.unpack(args))
  540. end
  541. end
  542. elseif getnamecallmethod() == "ScreenPointToRay" and not checkcaller() and mspoof then
  543. local args = {...}
  544. local pos = GetMouseLocation(UserInputService)
  545. if math.abs(args[1] - (pos.X + self.Offset.X)) <= 3 and math.abs(args[2] - (pos.Y + self.Offset.Y)) <= 3 then
  546. local newPos = workspace.CurrentCamera.WorldToScreenPoint(workspace.CurrentCamera, mspoof)
  547. args[1] = newPos.X
  548. args[2] = newPos.Y
  549. return old2(self2, table.unpack(args))
  550. else
  551. if math.abs(args[1] - (Mouse2.X + self.Offset.X)) <= 3 and math.abs(args[2] - (Mouse2.Y + self.Offset.Y)) <= 3 then
  552. local newPos = workspace.CurrentCamera.WorldToScreenPoint(workspace.CurrentCamera, mspoof)
  553. args[1] = newPos.X
  554. args[2] = newPos.Y
  555. return old2(self2, table.unpack(args))
  556. end
  557. end
  558. end
  559. return old2(self2, ...)
  560. end))
  561.  
  562. --[[
  563. local old2; old2 = hookmetamethod(game, "__namecall", function(self2, ...)
  564. local args = {...}
  565. if getnamecallmethod() == "ScreenPointToRay" or getnamecallmethod() == "ViewportPointToRay" and mspoof then
  566. local SecondPosition = game.GetService(game, "UserInputService").GetMouseLocation(game.GetService(game, "UserInputService"))
  567. if args[1] == Mouse2.X and args[2] == Mouse2.Y or args[1] == SecondPosition.X and args[2] == SecondPosition.Y then
  568. local newPos = workspace.CurrentCamera.WorldToScreenPoint(workspace.CurrentCamera, mspoof)
  569. args[1] = newPos.X
  570. args[2] = newPos.Y
  571. return old2(self2, table.unpack(args))
  572. end
  573. end
  574. return old2(self2, ...)
  575. end)
  576. --]]
  577. end
  578.  
  579. --//Completely kills aimbot, as opposed to enabled = false
  580. function Aimbot:Kill()
  581. self.Enabled = false
  582.  
  583. if self.RenderStep then
  584. Disconnect(self.RenderStep)
  585. self.RenderStep = nil
  586. end
  587.  
  588. if self.Heartbeat then
  589. Disconnect(self.Heartbeat)
  590. self.Heartbeat = nil
  591. end
  592. end
  593.  
  594. --//Constructor
  595. function Aimbot.new(presets)
  596. presets = presets or {}
  597. UpdateTable(presets, Aimbot.DefaultSettings)
  598.  
  599. local WallCheckParams = RaycastParams.new()
  600. WallCheckParams.FilterType = Enum.RaycastFilterType.Blacklist
  601. WallCheckParams.IgnoreWater = presets.IgnoreWater
  602. WallCheckParams.FilterDescendantsInstances = presets.DefaultIgnore
  603.  
  604. presets.WallCheckParams = WallCheckParams
  605. return setmetatable(presets, Aimbot)
  606. end
  607.  
  608. --//Return with default settings
  609. return Aimbot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement