HoangAnh_GaToVi

AimBot

Aug 14th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. local safe = setmetatable({}, {
  2.  
  3. __index = function(_, k)
  4. return game:GetService(k)
  5. end
  6. })
  7.  
  8. local movethemouse = Input.MoveMouse or mousemoverel --Mouse Move Function.
  9. local leftclickme = Input.KeyPress --Auto Shoot Key Press Thingy.
  10. local aimbotting = false -- Toggles.
  11. local autoshoot = false
  12. local teamcheck = true
  13. local vischeck = true
  14.  
  15. local cam = safe.Workspace.CurrentCamera -- Current Camera
  16. local lp = safe.Players.LocalPlayer -- Local Player
  17. local lpc = safe.Players.LocalPlayer.Character -- Local Player Character
  18.  
  19. local wtos = function(v) -- World To Screen
  20. return cam:WorldToScreenPoint(v)
  21. end
  22.  
  23. local distFromCenter = function(x, y)
  24. local vps = cam.ViewportSize -- Get ViewPortSize.
  25. local vpsx = vps.X
  26. local vpsy = vps.Y
  27. local screencenterx = vpsx/2
  28. local screencentery = vpsy/2
  29. local xdist = (x - screencenterx) -- X Distance From Mid Screen.
  30. local ydist = (y - screencentery) -- Y Distance From Mid Screen.
  31. local Hypotenuse = math.sqrt(math.pow(xdist, 2) + math.pow(ydist, 2))
  32. return Hypotenuse
  33. end
  34.  
  35. local function inlos(p, ...) -- In line of site?
  36. return #cam:GetPartsObscuringTarget({p}, {cam, lp.Character, ...}) == 0
  37. end
  38.  
  39. local getclosestPlayer = function() -- Checks the closest player based on Hypotenuse.
  40. local plrs, v = safe.Players:GetPlayers()
  41. local maxdist = 75
  42. local dist = 9e99
  43. local plr = "none"
  44. for i = 1, #plrs do
  45. v = plrs[i]
  46. if v ~= safe.Players.LocalPlayer then
  47. if v.Character then
  48. if v.Team ~= safe.Players.LocalPlayer.Team then
  49. local hpos = wtos(v.Character.Head.Position)
  50. local idist = distFromCenter(hpos.X, hpos.Y)
  51. if idist < dist and idist < maxdist then
  52. dist = idist
  53. plr = v
  54. end
  55. end
  56. end
  57. end
  58. end
  59. return plr, dist
  60. end
  61.  
  62. local AimAt = function(x, y)
  63. local vps = cam.ViewportSize
  64. local vpsx = vps.X
  65. local vpsy = vps.Y
  66. local screencenterx = vpsx/2
  67. local screencentery = vpsy/2
  68. local aimspeed = 5
  69. local aimatx
  70. local aimaty
  71.  
  72. if x ~= 0 then
  73. if x > screencenterx then
  74. aimatx = -(screencenterx - x)
  75. aimatx = aimatx/aimspeed
  76. if aimatx + screencenterx > screencenterx * 2 then
  77. aimatx = 0
  78. end
  79. end
  80. if x < screencenterx then
  81. aimatx = x - screencenterx
  82. aimatx = aimatx/aimspeed
  83. if aimatx + screencenterx < 0 then
  84. aimatx = 0
  85. end
  86. end
  87. end
  88.  
  89. if y ~= 0 then
  90. if y > screencentery then
  91. aimaty = -(screencentery - y)
  92. aimaty = aimaty/aimspeed
  93. if aimaty + screencentery > screencentery * 2 then
  94. aimaty = 0
  95. end
  96. end
  97. if y < screencentery then
  98. aimaty = y - screencentery
  99. aimaty = aimaty/aimspeed
  100. if aimaty + screencentery < 0 then
  101. aimaty = 0
  102. end
  103. end
  104. end
  105. return aimatx, aimaty
  106. end
  107.  
  108. local MouseTests = function()
  109. local player = safe.Players.LocalPlayer
  110. local mouse = player:GetMouse()
  111. local screensizex = mouse.ViewSizeX
  112. local screensizey = mouse.ViewSizeY
  113. local midx = screensizex/2
  114. local midy = screensizey/2
  115. local mousex = mouse.X
  116. local mousey = mouse.Y
  117. local moveamountx = midx - mousex
  118. local moveamounty = midy - mousey
  119. movethemouse(moveamountx, moveamounty)
  120. local camera = safe.Workspace.Camera
  121. local newmousex = safe.Players.LocalPlayer:GetMouse().X
  122. local newmousey = safe.Players.LocalPlayer:GetMouse().Y
  123. local closestplayer = getclosestPlayer()
  124. if player.Character.Humanoid.Health > 0 then
  125. if closestplayer ~= "none" then
  126. if inlos(closestplayer.Character.Head.Position, closestplayer.Character) then
  127. local closesthead = closestplayer.Character.Head
  128. local p = camera:WorldToScreenPoint(closesthead.Position)
  129. local xdistancetohead, ydistancetohead = AimAt(p.X, p.Y + 32)
  130. movethemouse(xdistancetohead, ydistancetohead)
  131. if autoshoot then
  132. Input.LeftClick(MOUSE_DOWN)
  133. wait()
  134. end
  135. end
  136. end
  137. end
  138. end
  139.  
  140. game:GetService('RunService').Stepped:connect(function()
  141. if aimbotting then
  142. --MouseTests()
  143. end
  144. end)
  145.  
  146.  
  147. local plr = safe.Players.LocalPlayer
  148. local mouse = plr:GetMouse()
  149. mouse.KeyDown:connect(function(key)
  150. if key == "t" then
  151. aimbotting = not aimbotting
  152. print("Aimbotting: " .. tostring(aimbotting))
  153. MouseTests()
  154. end
  155. if key == "o" then
  156. teamcheck = not teamcheck
  157. print("Team Check: " .. tostring(teamcheck))
  158. end
  159. end)
  160.  
  161.  
  162.  
  163. print("Pixel Aimbot Loaded!")
  164.  
  165. MB2Held = false
  166.  
  167. function onKeyPress(inputObject,gameProcessed)
  168. if inputObject.UserInputType == Enum.UserInputType.MouseButton2 then
  169. MB2Held = true
  170. while MB2Held do
  171. if aimbotting then
  172. MouseTests()
  173. end
  174. wait()
  175. end
  176. end
  177. end
  178.  
  179. function onKeyRelease(inputObject,gameProcessed)
  180. if inputObject.UserInputType == Enum.UserInputType.MouseButton2 then
  181. MB2Held = false
  182. end
  183. end
  184.  
  185. game:GetService("UserInputService").InputBegan:connect(onKeyPress)
  186. game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
Add Comment
Please, Sign In to add comment