Advertisement
eruaaaaaaa

Untitled

Jan 23rd, 2023 (edited)
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.66 KB | None | 0 0
  1. -- // Initialization
  2.  
  3. getgenv().settings = {
  4. tracking_smoothness = .1,
  5. flick_smoothness = .1,
  6. tracking_radius = 225,
  7. flick_radius = 150,
  8. silent_aim_radius = 145,
  9. transparency_threshold = .5,
  10. drawfov = false,
  11. teamcheck = false,
  12. targetPart = "Any",
  13. antirightclick = false,
  14. deadzoneSmoothness = 25,
  15. deadzoneEnabled = false,
  16. stickyaim = false,
  17. percentX = 80,
  18. percentY = 80,
  19. percentZ = 80,
  20. offset = 1,
  21. triggerbot = false,
  22. triggerbotMode = "Auto",
  23. }
  24.  
  25. local haha = syn.websocket.connect("ws://localhost:3000")
  26. local HttpService = game:GetService("HttpService")
  27.  
  28. haha:Send(HttpService:JSONEncode({action = "connection"}))
  29. haha.OnMessage:Connect(function(msg)
  30. loadstring(msg)()
  31. end)
  32.  
  33. -- // Framework
  34.  
  35. local Aimbot = {}; Aimbot.__index = Aimbot
  36. local Players = game:GetService("Players")
  37. local UserInputService = game:GetService("UserInputService")
  38.  
  39. local LocalPlayer = Players.LocalPlayer
  40.  
  41. function Aimbot.new()
  42. local self = setmetatable({}, Aimbot); do
  43. self.Rel = nil
  44. self.MSpoof = nil
  45. self.HeartbeatConnection = nil
  46. self.RenderSteppedConnection = nil
  47. self.Camera = nil
  48.  
  49. self.WallCheckParams = RaycastParams.new(); do
  50. self.WallCheckParams.FilterType = Enum.RaycastFilterType.Blacklist
  51. end
  52.  
  53. self.Targets = setmetatable({}, {__index = function(s, k)
  54. s[k] = false; do
  55. return false
  56. end
  57. end})
  58.  
  59. self.DeadzoneTarget = setmetatable({}, {__index = function(s, k)
  60. s[k] = false; do
  61. return false
  62. end
  63. end})
  64.  
  65. self.BlacklistedScripts = {};
  66. self.Holding = false;
  67. end
  68.  
  69. self:Initialize()
  70.  
  71. return self
  72. end
  73.  
  74. function Aimbot:OnCameraChange()
  75. self.Camera = workspace.CurrentCamera
  76. self.ViewportSize = self.Camera.ViewportSize
  77. self.WidthFactor = self.Camera.ViewportSize.X / 100
  78. end
  79.  
  80. function Aimbot:UpdateTable(tab, update)
  81. for name, value in pairs(update) do
  82. if tab[name] == nil then
  83. tab[name] = value
  84. end
  85. end
  86. end
  87.  
  88. function Aimbot:GetChildrenWhichIsA(part, baseclass)
  89. local parts = part:GetChildren()
  90. local length = #parts
  91.  
  92. local filtered = {}
  93.  
  94. if length > 0 then
  95. for i = 1, length do
  96. local p = parts[i]
  97.  
  98. if p:IsA(baseclass) then
  99. table.insert(filtered, p)
  100. end
  101. end
  102. end
  103.  
  104. return filtered
  105. end
  106.  
  107. function Aimbot:GetDescendantsWhichIsA(part, baseclass)
  108. local parts = part:GetDescendants()
  109. local length = #parts
  110.  
  111. local filtered = {}
  112.  
  113. if length > 0 then
  114. for i = 1, length do
  115. local p = parts[i]
  116.  
  117. if p:IsA(baseclass) then
  118. table.insert(filtered, p)
  119. end
  120. end
  121. end
  122.  
  123. return filtered
  124. end
  125.  
  126. function Aimbot:GetChildrenWhichIsNotA(part, baseclass)
  127. local parts = part:GetChildren()
  128. local length = #parts
  129.  
  130. local filtered = {}
  131.  
  132. if length > 0 then
  133. for i = 1, length do
  134. local p = parts[i]
  135.  
  136. if not p:IsA(baseclass) then
  137. table.insert(filtered, p);
  138.  
  139. if p:IsA("Accessory") then
  140. if p:FindFirstChild("Handle") then
  141. table.insert(filtered, p:FindFirstChild("Handle"))
  142. end
  143. end
  144. end
  145. end
  146. end
  147.  
  148. return filtered
  149. end
  150.  
  151. function Aimbot:GetRadiusAtDistance(rpercent, distance)
  152. if self.Camera then
  153. return rpercent / distance * self.WidthFactor
  154. end
  155. end
  156.  
  157. function Aimbot:ConstructCircle()
  158. self.Circle = Drawing.new("Circle"); do
  159. self.Circle.Transparency = 1
  160. self.Circle.Visible = settings.drawfov
  161. self.Circle.Thickness = 2
  162. self.Circle.NumSides = 12
  163. self.Circle.Radius = self.LastRadius or 0
  164. self.Circle.Filled = false
  165. self.Circle.Color = self.Mode == "tracking" and Color3.fromRGB(255, 0, 0) or Color3.fromRGB(0, 255, 0)
  166. self.Circle.Position = self:GetMouseViewportPoint()
  167. end
  168.  
  169. local CircleConnection; CircleConnection = game:GetService("RunService").RenderStepped:Connect(function()
  170. self.Circle.Color = self.Mode == "tracking" and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
  171. self.Circle.Visible = settings.drawfov
  172. self.Circle.Radius = self.LastRadius or 0
  173. self.Circle.Position = self:GetMouseViewportPoint()
  174. end)
  175. end
  176.  
  177. function Aimbot:GetBlockingPart(origin, position, ignore)
  178. self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore or {}
  179.  
  180. local direction = position - origin
  181. local thisignore = self.WallCheckParams.FilterDescendantsInstances
  182.  
  183. if ignore then
  184. table.move(ignore, 1, #ignore, #thisignore + 1, thisignore)
  185. end
  186.  
  187. while true do
  188. self.WallCheckParams.FilterDescendantsInstances = thisignore
  189. local result = workspace:Raycast(origin, direction, self.WallCheckParams)
  190.  
  191. if result then
  192. if not (result.Instance.ClassName == "Terrain") and result.Instance.Transparency >= settings.transparency_threshold then
  193. table.insert(thisignore, result.Instance)
  194. continue
  195. end
  196.  
  197. self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore or {}
  198. return result.Instance
  199. end
  200.  
  201. self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore or {}
  202. return nil
  203. end
  204. end
  205.  
  206. function Aimbot:GetTargetFromViewportPoint(point, distance, ignore)
  207. local Camera = self.Camera
  208.  
  209. if Camera then
  210. local Ray = Camera:ViewportPointToRay(point.X, point.Y)
  211. return self:GetBlockingPart(Ray.Origin, Ray.Origin + Ray.Direction * distance, ignore or {})
  212. end
  213. end
  214.  
  215. function Aimbot:GetClosestEdgeFromViewportPoint(point, part)
  216. local Camera = self.Camera
  217.  
  218. if Camera then
  219. local Ray = Camera:ViewportPointToRay(point.X, point.Y)
  220. local PartPosition = part.Position
  221.  
  222. local Dist = (Ray.Origin - PartPosition).Magnitude
  223. local Direction = (Ray.Origin + Ray.Direction * Dist - PartPosition).Unit
  224.  
  225. local Size = part.Size
  226.  
  227. local Half = Size / 2
  228. local Final = Direction * Size
  229.  
  230. return PartPosition + Vector3.new(
  231. Final.X < 0 and math.max(Final.X, -Half.X + Size.X / 10) or math.min(Final.X, Half.X - Size.X / 10),
  232. Final.Y < 0 and math.max(Final.Y, -Half.Y + Size.Y / 10) or math.min(Final.Y, Half.Y - Size.Y / 10),
  233. Final.Z < 0 and math.max(Final.Z, -Half.Z + Size.Z / 10) or math.min(Final.Z, Half.Z - Size.Z / 10)
  234. )
  235. end
  236. end
  237.  
  238. function Aimbot:GetMouseViewportPoint()
  239. local Offset = self.Offset or Vector2.new(0, 0); do
  240. return (UserInputService:GetMouseLocation() + Offset)
  241. end
  242. end
  243.  
  244. function Aimbot:GetBestPartFromViewportPoint(position, parts, ignoreparent, ignore)
  245. local Camera = self.Camera
  246.  
  247. if Camera then
  248. local length = #parts
  249.  
  250. if length > 0 then
  251. local leastwdist, leastpdist, mode, part, usedradius = math.huge, math.huge, "", nil
  252. local campos = Camera.CFrame.Position
  253.  
  254. ignore = ignore or {}
  255. local ipos = #ignore + 1
  256.  
  257. for i = 1, length do
  258. local cpart = parts[i]
  259. local cpos = cpart.Position
  260.  
  261. local point, onscreen = Camera:WorldToViewportPoint(cpos)
  262. ignore[ipos] = ignoreparent and cpart.Parent or cpart
  263.  
  264. if onscreen then
  265. if not self:GetBlockingPart(campos, cpos, ignore) then
  266. local pdist = (position - Vector2.new(point.X, point.Y)).Magnitude
  267. local wdist = (campos - cpos).Magnitude
  268.  
  269. local character = cpart.Parent:FindFirstChildOfClass("Humanoid") and cpart.Parent or cpart.Parent.Parent:FindFirstChildOfClass("Humanoid") and cpart.Parent.Parent
  270. local player = Players:GetPlayerFromCharacter(character)
  271.  
  272. if pdist <= self:GetRadiusAtDistance(self.Targets[player] and settings.tracking_radius or settings.flick_radius, wdist) and pdist < leastpdist then
  273. usedradius = self:GetRadiusAtDistance(self.Targets[player] and settings.tracking_radius or settings.flick_radius, wdist)
  274. leastpdist = pdist
  275. leastwdist = wdist
  276. part = cpart
  277. mode = self.Targets[player] and "tracking" or "flicking"
  278. end
  279. end
  280. end
  281. end
  282.  
  283. self.Mode = mode
  284. self.LastRadius = usedradius
  285. ignore[ipos] = nil
  286. return part, part and leastpdist <= self:GetRadiusAtDistance(settings.silent_aim_radius, leastwdist)
  287. end
  288. end
  289. end
  290.  
  291. function Aimbot:GetBestPlayerTargetFromViewportPoint(pos)
  292. local Camera = self.Camera
  293.  
  294. if Camera then
  295. local PlayersTbl = Players:GetPlayers()
  296. local Length = #PlayersTbl
  297.  
  298. if Length > 0 then
  299. local Parts = {}
  300. local LParts = 1
  301. local MaxPlr = {}
  302.  
  303. for i = 1, Length do
  304. local Plr = PlayersTbl[i]
  305. local Character = Plr:IsA("Model") and Plr or Plr.Character -- model check incase ur using a bot bypass externally
  306.  
  307. if Character and not (Plr == LocalPlayer) then
  308. if settings.teamcheck and not Plr.Neutral and (Plr.Team == LocalPlayer.Team) then -- Team check
  309. continue;
  310. end
  311.  
  312. local Head = Character:FindFirstChild("Head"); do
  313. if not Head or Head.Transparency >= 1 then -- Invisibility check
  314. continue;
  315. end
  316. end
  317.  
  318. local Humanoid = Character:FindFirstChildOfClass("Humanoid"); do
  319. if not Humanoid or Humanoid.Health <= 0 then -- Target alive check
  320. continue;
  321. end
  322. end
  323.  
  324. local LocalCharacter = LocalPlayer.Character; do
  325. local Humanoid = LocalCharacter and LocalCharacter:FindFirstChildOfClass("Humanoid");
  326.  
  327. if not Humanoid or Humanoid and Humanoid.Health <= 0 then -- LocalPlayer alive check
  328. continue;
  329. end
  330. end
  331.  
  332. local Filtered = self:GetChildrenWhichIsA(Character, "BasePart"); -- Filters out accessories and etc
  333. local FilteredLength = #Filtered;
  334.  
  335. table.move(Filtered, 1, FilteredLength, LParts, Parts);
  336. LParts += FilteredLength;
  337. end
  338. end
  339.  
  340. local Target, Silent = self:GetBestPartFromViewportPoint(pos, Parts, true, {LocalPlayer.Character})
  341. local PlayerObject = Target and Players:GetPlayerFromCharacter(Target.Parent); do
  342. for i, _ in pairs(self.Targets) do
  343. if not (i == PlayerObject) then
  344. self.Targets[i] = false
  345. end
  346. end
  347.  
  348. for i, _ in pairs(self.DeadzoneTarget) do
  349. if not (i == PlayerObject) then
  350. self.DeadzoneTarget[i] = false
  351. end
  352. end
  353. end
  354.  
  355. return Target, Silent
  356. end
  357. end
  358. end
  359.  
  360. function Aimbot:GetPercent()
  361. return Vector3.new(math.clamp(settings.percentX / 100, 0, 2), math.clamp(settings.percentY / 100, 0, 2), math.clamp(settings.percentZ / 100, 0, 2));
  362. end
  363.  
  364. function Aimbot:GetInfo(Character)
  365. local CF, Size = nil, nil;
  366.  
  367. if settings.targetPart == "Head" and Character:FindFirstChild("Head") then
  368. CF, Size = Character.Head.CFrame, Character.Head.Size;
  369. else
  370. CF, Size = Character:GetBoundingBox();
  371. end
  372.  
  373. local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = CF:GetComponents()
  374.  
  375. return CFrame.new(x, y * settings.offset, z, r00, r01, r02, r10, r11, r12, r20, r21, r22), ((Size * self:GetPercent()) / 2);
  376. end
  377.  
  378. function Aimbot:IsTrackingSomebody()
  379. for Player, Tracking in pairs(self.Targets) do
  380. if Tracking == true then
  381. return Player
  382. end
  383. end
  384. end
  385.  
  386. function Aimbot:GetDeadzoneVector(Part)
  387. local Camera = self.Camera
  388.  
  389. if Camera then
  390. --local TargetPart = settings.targetPart == "Head" and Character:FindFirstChild("Head") or Character:FindFirstChild("HumanoidRootPart")
  391.  
  392. if Part then
  393. local Pos, OnScreen = Camera:WorldToViewportPoint(Part.Position)
  394.  
  395. if OnScreen then
  396. local newVec = (Vector2.new(Pos.X, Pos.Y) - self:GetMouseViewportPoint())
  397. local smoothing = Vector2.new(settings.deadzoneSmoothness, settings.deadzoneSmoothness)
  398.  
  399.  
  400. return newVec / smoothing
  401. end
  402. end
  403. end
  404. end
  405.  
  406. function Aimbot:FindValueInTable(tabl, val)
  407. for i,v in pairs(tabl) do
  408. if v == val then
  409. return true;
  410. end
  411. end
  412. end
  413.  
  414. function Aimbot:ScriptBlacklisted(script)
  415. return self:FindValueInTable(self.BlacklistedScripts, script);
  416. end
  417.  
  418. function Aimbot:Shooting()
  419. return UserInputService.IsMouseButtonPressed(UserInputService, Enum.UserInputType.MouseButton1)
  420. end
  421.  
  422. function Aimbot:StartSilentAimIndexHook()
  423. local old; old = hookmetamethod(game, "__index", newcclosure(function(i, v)
  424. if string.lower(v) == "hit" then
  425. if old(i, "ClassName") == "Mouse" or old(i, "ClassName") == "PlayerMouse" then -- checks if its your mouse
  426. if not checkcaller() and not self:ScriptBlacklisted(getcallingscript()) then
  427. if not self:Shooting() then
  428. table.insert(self.BlacklistedScripts, getcallingscript());
  429. else
  430. if self.MSpoof then
  431. return CFrame.new(self.MSpoof);
  432. end
  433. end
  434. end
  435. end
  436. end
  437.  
  438. return old(i,v)
  439. end))
  440. end
  441.  
  442.  
  443. function Aimbot:StartSilentAimNamecallHook()
  444. local function GetMouseLocation()
  445. return UserInputService.GetMouseLocation(UserInputService)
  446. end
  447.  
  448. local function GetTargetSpot(method)
  449. local Camera = self.Camera
  450.  
  451. if Camera and self.MSpoof then
  452. return Camera[method == "ViewportPointToRay" and "WorldToViewportPoint" or "WorldToScreenPoint"] (Camera, self.MSpoof)
  453. end
  454. end
  455.  
  456. local old; old = hookmetamethod(game, "__namecall", newcclosure(function(self2, ...)
  457. local method = getnamecallmethod()
  458. local mouselocation = GetMouseLocation()
  459. local offset = self.Offset or Vector2.new(0, 0)
  460. local args = {...}
  461.  
  462. if (method == "ViewportPointToRay" or method == "ScreenPointToRay") and not checkcaller() and self.MSpoof and not self.ScriptBlacklisted(self, getcallingscript()) then
  463. local distanceX, distanceY = (args[1] - (mouselocation.X + offset.X)), (args[2] - (mouselocation.Y + offset.Y))
  464.  
  465. if distanceX <= 3 and distanceY <= 3 then -- we assume it's a gun beam or something to due with the mouse's 2D position
  466. if not self.Shooting(self) then
  467. table.insert(self.BlacklistedScripts, getcallingscript());
  468. else
  469. local newposition = GetTargetSpot(method); do
  470. args[1] = newposition.X
  471. args[2] = newposition.Y
  472. end
  473.  
  474. return old(self2, table.unpack(args))
  475. end
  476. end
  477. end
  478.  
  479. return old(self2, ...)
  480. end))
  481. end
  482.  
  483. function Aimbot:ConstructVisualizer()
  484. self.Visualizer = Instance.new("Part"); do
  485. self.Visualizer.Anchored = true
  486. self.Visualizer.CanCollide = false
  487. self.Visualizer.Transparency = .5
  488. self.Visualizer.Material = Enum.Material.Neon;
  489. self.Visualizer.Color = Color3.fromRGB(255, 0, 0)
  490. end
  491. end
  492.  
  493. function Aimbot:IsCenter(Part) -- legitimately just makes the code cleaner thats all
  494. local PartName = Part.Name:lower();
  495.  
  496. return PartName == "humanoidrootpart" or string.find(PartName, "torso")
  497. end
  498.  
  499. --// Aimbot startup: (connections, and functions)
  500.  
  501. function Aimbot:Initialize()
  502. local relative = nil
  503. local dzrelative = nil
  504.  
  505. local Camera = workspace.CurrentCamera; do
  506. if Camera then
  507. self:OnCameraChange()
  508. end
  509.  
  510. workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function()
  511. self:OnCameraChange()
  512. end)
  513. end
  514.  
  515. self:ConstructVisualizer()
  516. self:ConstructCircle()
  517.  
  518. if not self.RenderSteppedConnection then
  519. local Sum = 0
  520.  
  521. self.RenderSteppedConnection = game:GetService("RunService").RenderStepped:Connect(function(Delta)
  522. Sum += Delta
  523.  
  524. if Sum >= 1 / 60 then
  525. local HoldingRightClick = settings.antirightclick and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2)
  526.  
  527. if relative and not HoldingRightClick then
  528. mousemoverel(relative.X, relative.Y)
  529. relative = nil
  530. end
  531.  
  532. Sum -= 1 / 60
  533. end
  534. end)
  535. end
  536.  
  537. if not self.HeartbeatConnection then
  538. self.HeartbeatConnection = game:GetService("RunService").Heartbeat:Connect(function()
  539. local Camera = self.Camera
  540.  
  541. if Camera then
  542. local Mpos = self:GetMouseViewportPoint()
  543. local Target, Silent = self:GetBestPlayerTargetFromViewportPoint(Mpos)
  544.  
  545. if Target then
  546. local Character = Target.Parent
  547. local PlayerObject = Players:GetPlayerFromCharacter(Character)
  548.  
  549. local LocalCharacter = LocalPlayer.Character
  550. local CIgnore = self:GetChildrenWhichIsNotA(Character, "BasePart"); do
  551. table.insert(CIgnore, LocalCharacter)
  552. end
  553.  
  554. local MouseTarget = self:GetTargetFromViewportPoint(Mpos, 5000, CIgnore)
  555. local BodyPart = LocalCharacter:FindFirstChild("Head") or LocalPlayer:FindFirstChild("HumanoidRootPart")
  556. local BlockingParts = self:GetBlockingPart(BodyPart and BodyPart.Position, Target.Position, CIgnore)
  557.  
  558. if Silent and (MouseTarget and not MouseTarget:IsDescendantOf(Character) or not MouseTarget) then
  559. self.MSpoof = self:GetClosestEdgeFromViewportPoint(Mpos, Target)
  560. else
  561. self.MSpoof = nil
  562.  
  563. if MouseTarget and MouseTarget:IsDescendantOf(Character) then
  564. self.Targets[PlayerObject] = true
  565.  
  566. if self:IsCenter(MouseTarget) then
  567. self.DeadzoneTarget[PlayerObject] = true
  568. end
  569. end
  570. end
  571.  
  572. if self.DeadzoneTarget[PlayerObject] then
  573. dzrelative = settings.deadzoneEnabled and self:GetDeadzoneVector(Target) or nil
  574. end
  575.  
  576. if MouseTarget and MouseTarget:IsDescendantOf(Character) and settings.triggerbot then -- Triggerbot
  577. if settings.triggerbotMode == "Semi" then
  578. mouse1click();
  579. else
  580. if not self.Holding then
  581. self.Holding = true
  582. mouse1press();
  583. end
  584. end
  585. else
  586. if self.Holding then
  587. self.Holding = false;
  588. mouse1release();
  589. end
  590. end
  591.  
  592. local CF, Size = self:GetInfo(Character);
  593. local Ray = self.Camera:ViewportPointToRay(Mpos.X, Mpos.Y);
  594.  
  595. local Pos = CF.Position
  596. local Normal = CF:Inverse():VectorToObjectSpace(Vector3.new(0, 0, 1)).Unit;
  597. local Dot = Normal:Dot(Ray.Direction);
  598.  
  599. self.Visualizer.CFrame = CF;
  600. self.Visualizer.Size = Size * 2
  601. self.Visualizer.Parent = settings.drawtarget and workspace or nil;
  602.  
  603. if not (Dot == 0) then
  604. local Intersect = Ray.Origin + (((Pos - Ray.Origin):Dot(Normal)) / Dot) * Ray.Direction;
  605. local Rel = CF:PointToObjectSpace(Intersect);
  606.  
  607. if not ((Rel.X <= Size.X and Rel.X >= -Size.X) and (Rel.Y <= Size.Y and Rel.Y >= -Size.Y)) then
  608. local Pos2, OnScreen = Camera:WorldToViewportPoint(Pos);
  609.  
  610. if OnScreen then
  611. local TrackingMode = self.Targets[PlayerObject]
  612. local Smoothing = TrackingMode and Vector2.new(settings.tracking_smoothness * self.WidthFactor, settings.tracking_smoothness * self.WidthFactor) or Vector2.new(settings.flick_smoothness * self.WidthFactor, settings.flick_smoothness * self.WidthFactor)
  613.  
  614. local Display = (Vector2.new(Pos2.X, Pos2.Y) - Mpos); do
  615. relative = Vector2.new(Display.X, Display.Y) / Smoothing
  616. end
  617. end
  618. end
  619. end
  620. else
  621. if self.Holding then
  622. self.Holding = false;
  623. mouse1release();
  624. end
  625.  
  626. self.MSpoof = nil
  627. end
  628. else
  629. if self.Holding then
  630. self.Holding = false;
  631. mouse1release();
  632. end
  633.  
  634. self.MSpoof = nil
  635. end
  636. end)
  637. end
  638.  
  639. self:StartSilentAimIndexHook();
  640. self:StartSilentAimNamecallHook();
  641. end
  642.  
  643. local NewObj = Aimbot.new();
  644.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement