Advertisement
SirMeme

Phantom Forces Aimbot

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