Advertisement
Guest User

Untitled

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