Advertisement
real2322

Universal Aimbot Script

May 10th, 2022
5,851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.95 KB | None | 0 0
  1. if not syn or not protectgui then
  2. getgenv().protectgui = function()end
  3. end
  4. local Library = loadstring(game:HttpGet('https://raw.githubusercontent.com/mitka1337/lib-not-my-lib-/main/lib.lua'))()
  5. Library:SetWatermark("github.com/ZeInSoRiTy")
  6. local Camera = workspace.CurrentCamera
  7. local Players = game:GetService("Players")
  8. local RunService = game:GetService("RunService")
  9. local GuiService = game:GetService("GuiService")
  10.  
  11. local LocalPlayer = Players.LocalPlayer
  12. local Mouse = LocalPlayer:GetMouse()
  13.  
  14. local GetChildren = game.GetChildren
  15. local WorldToScreen = Camera.WorldToScreenPoint
  16. local WorldToViewportPoint = Camera.WorldToViewportPoint
  17. local GetPartsObscuringTarget = Camera.GetPartsObscuringTarget
  18. local FindFirstChild = game.FindFirstChild
  19. local RenderStepped = RunService.RenderStepped
  20. local GuiInset = GuiService.GetGuiInset
  21.  
  22. local resume = coroutine.resume
  23. local create = coroutine.create
  24.  
  25. local ValidTargetParts = {"Head", "HumanoidRootPart"};
  26.  
  27. local function getPositionOnScreen(Vector)
  28. local Vec3, OnScreen = WorldToScreen(Camera, Vector)
  29. return Vector2.new(Vec3.X, Vec3.Y), OnScreen
  30. end
  31.  
  32. local function ValidateArguments(Args, RayMethod)
  33. local Matches = 0
  34. if #Args < RayMethod.ArgCountRequired then
  35. return false
  36. end
  37. for Pos, Argument in next, Args do
  38. if typeof(Argument) == RayMethod.Args[Pos] then
  39. Matches = Matches + 1
  40. end
  41. end
  42. return Matches >= RayMethod.ArgCountRequired
  43. end
  44.  
  45. local function getDirection(Origin, Position)
  46. return (Position - Origin).Unit * 1000
  47. end
  48.  
  49. local function getMousePosition()
  50. return Vector2.new(Mouse.X, Mouse.Y)
  51. end
  52.  
  53. local function IsPlayerVisible(Player)
  54. local PlayerCharacter = Player.Character
  55. local LocalPlayerCharacter = LocalPlayer.Character
  56.  
  57. if not (PlayerCharacter or LocalPlayerCharacter) then return end
  58.  
  59. local PlayerRoot = FindFirstChild(PlayerCharacter, Options.TargetPart.Value) or FindFirstChild(PlayerCharacter, "HumanoidRootPart")
  60.  
  61. if not PlayerRoot then return end
  62.  
  63. local CastPoints, IgnoreList = {PlayerRoot.Position, LocalPlayerCharacter, PlayerCharacter}, {LocalPlayerCharacter, PlayerCharacter}
  64. local ObscuringObjects = #GetPartsObscuringTarget(Camera, CastPoints, IgnoreList)
  65.  
  66. return ((ObscuringObjects == 0 and true) or (ObscuringObjects > 0 and false))
  67. end
  68.  
  69. local function getClosestPlayer()
  70. if not Options.TargetPart.Value then return end
  71. local Closest
  72. local DistanceToMouse
  73. for _, Player in next, GetChildren(Players) do
  74. if Player == LocalPlayer then continue end
  75. if Toggles.TeamCheck.Value and Player.Team == LocalPlayer.Team then continue end
  76.  
  77. local Character = Player.Character
  78. if not Character then continue end
  79.  
  80. if Toggles.VisibleCheck.Value and not IsPlayerVisible(Player) then continue end
  81.  
  82. local HumanoidRootPart = FindFirstChild(Character, "HumanoidRootPart")
  83. local Humanoid = FindFirstChild(Character, "Humanoid")
  84.  
  85. if not HumanoidRootPart or not Humanoid or Humanoid and Humanoid.Health <= 0 then continue end
  86.  
  87. local ScreenPosition, OnScreen = getPositionOnScreen(HumanoidRootPart.Position)
  88.  
  89. if not OnScreen then continue end
  90.  
  91. local Distance = (getMousePosition() - ScreenPosition).Magnitude
  92. if Distance <= (DistanceToMouse or (Toggles.fov_Enabled.Value and Options.Radius.Value) or 2000) then
  93. Closest = ((Options.TargetPart.Value == "Random" and Character[ValidTargetParts[math.random(1, #ValidTargetParts)]]) or Character[Options.TargetPart.Value])
  94. DistanceToMouse = Distance
  95. end
  96. end
  97. return Closest
  98. end
  99.  
  100. local Window = Library:CreateWindow("Universal Silent Aim")
  101.  
  102. local GeneralTab = Window:AddTab("General")
  103. local MainBOX = GeneralTab:AddLeftTabbox("Main")
  104. do
  105. local Main = MainBOX:AddTab("Main")
  106. Main:AddToggle("aim_Enabled", {Text = "Enabled"})
  107. Main:AddToggle("TeamCheck", {Text = "Team Check"})
  108. Main:AddToggle("VisibleCheck", {Text = "Visible Check"})
  109. Main:AddDropdown("TargetPart", {Text = "Target Part", Default = 1, Values = {
  110. "Head", "HumanoidRootPart", "Random"
  111. }})
  112. Main:AddDropdown("Method", {Text = "Silent Aim Method", Default = 1, Values = {
  113. "Raycast","FindPartOnRay",
  114. "FindPartOnRayWithWhitelist",
  115. "FindPartOnRayWithIgnoreList",
  116. "Mouse.Hit/Target"
  117. }})
  118. end
  119.  
  120. local FieldOfViewBOX = GeneralTab:AddLeftTabbox("Field Of View")
  121. local MiscellaneousBOX = GeneralTab:AddLeftTabbox("Miscellaneous")
  122.  
  123. local fov_circle = Drawing.new("Circle")
  124. fov_circle.Thickness = 1
  125. fov_circle.NumSides = 100
  126. fov_circle.Radius = 180
  127. fov_circle.Filled = false
  128. fov_circle.Visible = false
  129. fov_circle.ZIndex = 999
  130. fov_circle.Transparency = 1
  131. fov_circle.Color = Color3.fromRGB(54, 57, 241)
  132.  
  133. local mouse_box = Drawing.new("Square")
  134. mouse_box.Visible = true
  135. mouse_box.ZIndex = 999
  136. mouse_box.Color = Color3.fromRGB(54, 57, 241)
  137. mouse_box.Thickness = 20
  138. mouse_box.Size = Vector2.new(20, 20)
  139. mouse_box.Filled = true
  140.  
  141. local PredictionAmount = 0.165
  142.  
  143. do
  144. local Main = FieldOfViewBOX:AddTab("Field Of View")
  145. Main:AddToggle("fov_Enabled", {Text = "Enabled"})
  146. Main:AddSlider("Radius", {Text = "Radius", Min = 0, Max = 360, Default = 180, Rounding = 0}):OnChanged(function()
  147. fov_circle.Radius = Options.Radius.Value
  148. end)
  149. Main:AddToggle("Visible", {Text = "Visible"}):AddColorPicker("Color", {Default = Color3.fromRGB(54, 57, 241)}):OnChanged(function()
  150. fov_circle.Visible = Toggles.Visible.Value
  151. end)
  152. Main:AddToggle("MousePosition", {Text = "Show Fake Mouse Position"}):AddColorPicker("MouseVisualizeColor", {Default = Color3.fromRGB(54, 57, 241)}):OnChanged(function()
  153. mouse_box.Visible = Toggles.MousePosition.Value
  154. end)
  155.  
  156. local PredictionTab = MiscellaneousBOX:AddTab("Prediction")
  157. PredictionTab:AddToggle("Prediction", {Text = "Mouse.Hit/Target Prediction"})
  158. PredictionTab:AddSlider("Amount", {Text = "Prediction Amount", Min = 0.165, Max = 1, Default = 0.165, Rounding = 3}):OnChanged(function()
  159. PredictionAmount = Options.Amount.Value
  160. end)
  161. end
  162.  
  163. resume(create(function()
  164. RenderStepped:Connect(function()
  165. if Toggles.MousePosition.Value then
  166. if Toggles.aim_Enabled.Value == true and Options.Method.Value == "Mouse.Hit/Target" then
  167. mouse_box.Color = Options.MouseVisualizeColor.Value
  168.  
  169. mouse_box.Visible = ((getClosestPlayer() and true) or false)
  170. mouse_box.Position = ((getClosestPlayer() and Vector2.new(WorldToViewportPoint(Camera, getClosestPlayer().Parent.PrimaryPart.Position).X, WorldToViewportPoint(Camera, getClosestPlayer().Parent.PrimaryPart.Position).Y)) or Vector2.new(-9000, -9000)) -- I am too lazy to write this differently - xaxa
  171. end
  172. end
  173.  
  174. if Toggles.Visible.Value then
  175. fov_circle.Visible = Toggles.Visible.Value
  176. fov_circle.Color = Options.Color.Value
  177. fov_circle.Position = getMousePosition() + Vector2.new(0, 36)
  178. end
  179. end)
  180. end))
  181.  
  182. local ExpectedArguments = {
  183. FindPartOnRayWithIgnoreList = {
  184. ArgCountRequired = 3,
  185. Args = {
  186. "Instance", "Ray", "table", "boolean", "boolean"
  187. }
  188. },
  189. FindPartOnRayWithWhitelist = {
  190. ArgCountRequired = 3,
  191. Args = {
  192. "Instance", "Ray", "table", "boolean"
  193. }
  194. },
  195. FindPartOnRay = {
  196. ArgCountRequired = 2,
  197. Args = {
  198. "Instance", "Ray", "Instance", "boolean", "boolean"
  199. }
  200. },
  201. Raycast = {
  202. ArgCountRequired = 3,
  203. Args = {
  204. "Instance", "Vector3", "Vector3", "RaycastParams"
  205. }
  206. }
  207. }
  208.  
  209. local oldNamecall
  210. oldNamecall = hookmetamethod(game, "__namecall", function(...)
  211. local Method = getnamecallmethod()
  212. local Arguments = {...}
  213. local self = Arguments[1]
  214.  
  215. if Toggles.aim_Enabled.Value and self == workspace then
  216. if Method == "FindPartOnRayWithIgnoreList" and Options.Method.Value == Method then
  217. if ValidateArguments(Arguments, ExpectedArguments.FindPartOnRayWithIgnoreList) then
  218. local A_Ray = Arguments[2]
  219.  
  220. local HitPart = getClosestPlayer()
  221. if HitPart then
  222. local Origin = A_Ray.Origin
  223. local Direction = getDirection(Origin, HitPart.Position)
  224. Arguments[2] = Ray.new(Origin, Direction)
  225.  
  226. return oldNamecall(unpack(Arguments))
  227. end
  228. end
  229. elseif Method == "FindPartOnRayWithWhitelist" and Options.Method.Value == Method then
  230. if ValidateArguments(Arguments, ExpectedArguments.FindPartOnRayWithWhitelist) then
  231. local A_Ray = Arguments[2]
  232.  
  233. local HitPart = getClosestPlayer()
  234. if HitPart then
  235. local Origin = A_Ray.Origin
  236. local Direction = getDirection(Origin, HitPart.Position)
  237. Arguments[2] = Ray.new(Origin, Direction)
  238.  
  239. return oldNamecall(unpack(Arguments))
  240. end
  241. end
  242. elseif (Method == "FindPartOnRay" or Method == "findPartOnRay") and Options.Method.Value:lower() == Method:lower() then
  243. if ValidateArguments(Arguments, ExpectedArguments.FindPartOnRay) then
  244. local A_Ray = Arguments[2]
  245.  
  246. local HitPart = getClosestPlayer()
  247. if HitPart then
  248. local Origin = A_Ray.Origin
  249. local Direction = getDirection(Origin, HitPart.Position)
  250. Arguments[2] = Ray.new(Origin, Direction)
  251.  
  252. return oldNamecall(unpack(Arguments))
  253. end
  254. end
  255. elseif Method == "Raycast" and Options.Method.Value == Method then
  256. if ValidateArguments(Arguments, ExpectedArguments.Raycast) then
  257. local A_Origin = Arguments[2]
  258.  
  259. local HitPart = getClosestPlayer()
  260. if HitPart then
  261. Arguments[3] = getDirection(A_Origin, HitPart.Position)
  262.  
  263. return oldNamecall(unpack(Arguments))
  264. end
  265. end
  266. end
  267. end
  268. return oldNamecall(...)
  269. end)
  270.  
  271. local oldIndex = nil
  272. oldIndex = hookmetamethod(game, "__index", function(self, Index)
  273. if self == Mouse and (Index == "Hit" or Index == "Target") then
  274. if Toggles.aim_Enabled.Value == true and Options.Method.Value == "Mouse.Hit/Target" and getClosestPlayer() then
  275. local HitPart = getClosestPlayer()
  276.  
  277. return ((Index == "Hit" and ((Toggles.Prediction.Value == false and HitPart.CFrame) or (Toggles.Prediction.Value == true and (HitPart.CFrame + (HitPart.Velocity * PredictionAmount))))) or (Index == "Target" and HitPart))
  278. end
  279. end
  280.  
  281. return oldIndex(self, Index)
  282. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement