Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 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 --Mouse Move Function.
  8. local leftclickme = nil --Auto Shoot Key Press Thingy.
  9. local aimbotting = true -- Toggles.
  10. local autoshoot = false
  11. local teamcheck = false
  12. _G.xaimoffset = 0 --_G.xaimoffset = -25
  13. _G.maxdistfromcross = 179
  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.  
  36. local getclosestPlayer = function() -- Checks the closest player based on Hypotenuse.
  37. local plrs, v = safe.Players:GetPlayers()
  38. local maxdist = 75
  39. local dist = math.huge
  40. local plr = "none"
  41. for i = 1, #plrs do
  42. v = plrs[i]
  43. if v ~= safe.Players.LocalPlayer then
  44. if v.Character and v.Character:WaitForChild("Head",10) then
  45. if v.TeamColor ~= safe.Players.LocalPlayer.TeamColor and teamcheck then
  46. local hpos = wtos(v.Character.Head.Position)
  47. local idist = distFromCenter(hpos.X, hpos.Y)
  48. if idist < dist and idist < _G.maxdistfromcross then
  49. dist = idist
  50. plr = v
  51. end
  52. elseif not teamcheck then
  53. local hpos = wtos(v.Character.Head.Position)
  54. local idist = distFromCenter(hpos.X, hpos.Y)
  55. if idist < dist and idist < _G.maxdistfromcross then
  56. dist = idist
  57. plr = v
  58. end
  59. end
  60. end
  61. end
  62. end
  63. return plr, dist
  64. end
  65.  
  66. local AimAt = function(x, y)
  67. local vps = cam.ViewportSize
  68. local vpsx = vps.X
  69. local vpsy = vps.Y
  70. local screencenterx = vpsx/2
  71. local screencentery = vpsy/2
  72. local aimspeed = 2
  73. local aimatx
  74. local aimaty
  75.  
  76. if x ~= 0 then
  77. if x > screencenterx then
  78. aimatx = -(screencenterx - x)
  79. aimatx = aimatx/aimspeed
  80. if aimatx + screencenterx > screencenterx * 2 then
  81. aimatx = 0
  82. end
  83. end
  84. if x < screencenterx then
  85. aimatx = x - screencenterx
  86. aimatx = aimatx/aimspeed
  87. if aimatx + screencenterx < 0 then
  88. aimatx = 0
  89. end
  90. end
  91. end
  92.  
  93. if y ~= 0 then
  94. if y > screencentery then
  95. aimaty = -(screencentery - y)
  96. aimaty = aimaty/aimspeed
  97. if aimaty + screencentery > screencentery * 2 then
  98. aimaty = 0
  99. end
  100. end
  101. if y < screencentery then
  102. aimaty = y - screencentery
  103. aimaty = aimaty/aimspeed
  104. if aimaty + screencentery < 0 then
  105. aimaty = 0
  106. end
  107. end
  108. end
  109. return aimatx, aimaty
  110. end
  111.  
  112. local MouseTests = function()
  113. local player = safe.Players.LocalPlayer
  114. local mouse = player:GetMouse()
  115. local screensizex = mouse.ViewSizeX
  116. local screensizey = mouse.ViewSizeY
  117. local midx = screensizex/2
  118. local midy = screensizey/2
  119. local mousex = mouse.X
  120. local mousey = mouse.Y
  121. local moveamountx = midx - mousex
  122. local moveamounty = midy - mousey
  123.  
  124. local camera = safe.Workspace.Camera
  125. local newmousex = safe.Players.LocalPlayer:GetMouse().X
  126. local newmousey = safe.Players.LocalPlayer:GetMouse().Y
  127. local closestplayer = getclosestPlayer()
  128. if player.Character.Humanoid.Health > 0 then
  129. if closestplayer ~= "none" then
  130.  
  131. local closesthead = closestplayer.Character:WaitForChild("Head",10)
  132. if closesthead then
  133. local p = camera:WorldToScreenPoint(closesthead.Position)
  134. local xdistancetohead, ydistancetohead = AimAt(p.X + _G.xaimoffset, p.Y + 35)
  135. movethemouse(moveamountx + xdistancetohead, moveamounty + ydistancetohead)
  136. end
  137.  
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement