KingPhantom

badbusniness

Nov 14th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 = false -- Toggles.
  10. local autoshoot = false
  11. local teamcheck = true
  12. local visiblecheck = false
  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, game.Workspace.Characters[lp.Name].Body, ...}) == 0
  38. end
  39.  
  40. local function CheckIfNotTeamed(EnemyPlayer)
  41.     if game.Teams.Omega.Players:FindFirstChild(EnemyPlayer.Name) then
  42.         if game.Teams.Omega.Players:FindFirstChild(lp.Name) then
  43.             return false
  44.         else
  45.             return true
  46.         end
  47.     else
  48.         if game.Teams.Beta.Players:FindFirstChild(lp.Name) then
  49.             return false
  50.         else
  51.             return true
  52.         end
  53.     end
  54. end
  55.  
  56. local getclosestPlayer = function() -- Checks the closest player based on Hypotenuse.
  57.     local plrs = game.Workspace.Characters:GetChildren()
  58.     local v
  59.     local maxdist = 75
  60.     local dist = math.huge
  61.     local plr = "none"
  62.     for i = 1, #plrs do
  63.         v = plrs[i]
  64.         if v.Name ~= safe.Players.LocalPlayer.Name then
  65.             if game.Workspace.Characters[v.Name] then
  66.                 if CheckIfNotTeamed(v) and teamcheck then
  67.                     local hpos = wtos(game.Workspace.Characters[v.Name].Body.Head.Position)
  68.                     local idist = distFromCenter(hpos.X, hpos.Y)
  69.                     if idist < dist and idist < _G.maxdistfromcross then
  70.                         dist = idist
  71.                         plr = v
  72.                     end
  73.                 elseif not teamcheck then
  74.                     local hpos = wtos(game.Workspace.Characters[v.Name].Body.Head.Position)
  75.                     local idist = distFromCenter(hpos.X, hpos.Y)
  76.                     if idist < dist and idist < _G.maxdistfromcross then
  77.                         dist = idist
  78.                         plr = v
  79.                     end
  80.                 end
  81.             end
  82.         end
  83.     end
  84.     return plr, dist
  85. end
  86.  
  87. local AimAt = function(x, y)
  88.     local vps = cam.ViewportSize
  89.     local vpsx = vps.X
  90.     local vpsy = vps.Y
  91.     local screencenterx = vpsx/2
  92.     local screencentery = vpsy/2
  93.     local aimspeed = 5
  94.     local aimatx
  95.     local aimaty
  96.  
  97.     if x ~= 0 then
  98.         if x > screencenterx then
  99.             aimatx = -(screencenterx - x)
  100.             aimatx = aimatx/aimspeed
  101.             if aimatx + screencenterx > screencenterx * 2 then
  102.                 aimatx = 0
  103.             end
  104.         end
  105.         if x < screencenterx then
  106.             aimatx = x - screencenterx
  107.             aimatx = aimatx/aimspeed
  108.             if aimatx + screencenterx < 0 then
  109.                 aimatx = 0
  110.             end
  111.         end
  112.     end
  113.  
  114.     if y ~= 0 then
  115.         if y > screencentery then
  116.             aimaty = -(screencentery - y)
  117.             aimaty = aimaty/aimspeed
  118.             if aimaty + screencentery > screencentery * 2 then
  119.                 aimaty = 0
  120.             end
  121.         end
  122.         if y < screencentery then
  123.             aimaty = y - screencentery
  124.             aimaty = aimaty/aimspeed
  125.             if aimaty + screencentery < 0 then
  126.                 aimaty = 0
  127.             end
  128.         end
  129.     end
  130.     return aimatx, aimaty
  131. end
  132.  
  133. local MouseTests = function()
  134.     local player = safe.Players.LocalPlayer
  135.     local mouse = player:GetMouse()
  136.     local screensizex = mouse.ViewSizeX
  137.     local screensizey = mouse.ViewSizeY
  138.     local midx = screensizex/2
  139.     local midy = screensizey/2
  140.     local mousex = mouse.X
  141.     local mousey = mouse.Y
  142.     local moveamountx = midx - mousex
  143.     local moveamounty = midy - mousey
  144.     movethemouse(moveamountx, moveamounty)
  145.     local camera = safe.Workspace.Camera
  146.     local newmousex = safe.Players.LocalPlayer:GetMouse().X
  147.     local newmousey = safe.Players.LocalPlayer:GetMouse().Y
  148.     local closestplayer = getclosestPlayer()
  149.     if game.Workspace.Characters[player.Name].Health.Value > 0 then
  150.         if closestplayer ~= "none" then
  151.             if inlos(game.Workspace.Characters[closestplayer.Name].Body.Head.Position, closestplayer.Body) and visiblecheck then
  152.                 local closesthead = game.Workspace.Characters[closestplayer.Name].Body.Head
  153.                 local p = camera:WorldToScreenPoint(closesthead.Position)
  154.                 local xdistancetohead, ydistancetohead = AimAt(p.X + _G.xaimoffset, p.Y + 32)
  155.                 movethemouse(xdistancetohead, ydistancetohead)
  156.                 if autoshoot then
  157.                     movethemouse(xdistancetohead, ydistancetohead)
  158.                     wait(1)
  159.                     Input.LeftClick(MOUSE_DOWN)
  160.                     wait()
  161.                 end
  162.             elseif not visiblecheck then
  163.                 local closesthead = game.Workspace.Characters[closestplayer.Name].Body.Head
  164.                 local p = camera:WorldToScreenPoint(closesthead.Position)
  165.                 local xdistancetohead, ydistancetohead = AimAt(p.X + _G.xaimoffset, p.Y + 32)
  166.                 movethemouse(xdistancetohead, ydistancetohead)
  167.             end
  168.         end
  169.     end
  170. end
  171.  
  172. game:GetService('RunService').Stepped:connect(function()
  173.     if aimbotting then
  174.     --MouseTests()
  175.     end
  176. end)
  177.  
  178.  
  179. local plr = safe.Players.LocalPlayer
  180. local mouse = plr:GetMouse()
  181. mouse.KeyDown:connect(function(key)
  182.     if key == "t" then
  183.         aimbotting = not aimbotting
  184.         print("Aimbotting: " .. tostring(aimbotting))
  185.         MouseTests()
  186.     end
  187.     if key == "o" then
  188.         visiblecheck = not visiblecheck
  189.         print("Visible Check: " .. tostring(visiblecheck))
  190.     end
  191.  
  192.     if key == "]" then
  193.         teamcheck = not teamcheck
  194.         print("Team Check: " .. tostring(teamcheck))
  195.     end
  196. end)
  197.  
  198.  
  199.  
  200. print("Pixel Aimbot Loaded!")
  201.  
  202. MB2Held = false
  203.  
  204. function onKeyPress(inputObject,gameProcessed)
  205.     if inputObject.UserInputType == Enum.UserInputType.MouseButton2 then
  206.         MB2Held = true
  207.         while MB2Held do
  208.             if aimbotting then
  209.                 MouseTests()
  210.             end
  211.             wait()
  212.         end
  213.     end
  214. end
  215.  
  216. function onKeyRelease(inputObject,gameProcessed)
  217.     if inputObject.UserInputType == Enum.UserInputType.MouseButton2 then
  218.         MB2Held = false
  219.     end
  220. end
  221.  
  222. game:GetService("UserInputService").InputBegan:connect(onKeyPress)
  223. game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
Add Comment
Please, Sign In to add comment