Advertisement
DesiredPaths

Untitled

May 22nd, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. local mouse = game:GetService("Players").LocalPlayer:GetMouse()
  2. local hold=false
  3.  
  4. --settings
  5. local keybind=Enum.KeyCode.Q
  6. local enablepconsole=false
  7. local fov=250
  8. local teamcheck=false
  9.  
  10. if teamcheck then
  11. if #game.Teams:GetChildren()<2 then
  12. if enablepconsole then
  13. rconsoleprint("\nthere are less then 2 teams in this game! disabled teamcheck")
  14. else
  15. warn("there are less then 2 teams in this game! disabled teamcheck")
  16. end
  17. teamcheck=false
  18. end
  19. end
  20.  
  21. function getnearest()
  22. local nearest
  23. local kanker=math.huge
  24. for i,v in next, game:GetService("Players"):GetChildren() do
  25. if v and v.Character and v~=game:GetService("Players").LocalPlayer and v.Character:FindFirstChild("Head") and v.Character:FindFirstChild("Humanoid") and v.Character:FindFirstChild("Humanoid").Health>0 then
  26. if teamcheck then
  27. if v.Team ~= game.Players.LocalPlayer.Team then
  28. local worldPoint = v.Character.Head.Position
  29. local vector, onScreen = workspace.CurrentCamera:WorldToScreenPoint(worldPoint)
  30. local magnitude = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(vector.X, vector.Y)).magnitude
  31. if kanker>magnitude and onScreen and magnitude<fov then
  32. kanker=magnitude
  33. nearest=v
  34. end
  35. end
  36. else
  37. local worldPoint = v.Character.Head.Position
  38. local vector, onScreen = workspace.CurrentCamera:WorldToScreenPoint(worldPoint)
  39. local magnitude = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(vector.X, vector.Y)).magnitude
  40. if kanker>magnitude and onScreen and magnitude<fov then
  41. kanker=magnitude
  42. nearest=v
  43. end
  44. end
  45. end
  46. end
  47. return nearest
  48. end
  49.  
  50. game:GetService("UserInputService").InputBegan:connect(function(input)
  51. if input.KeyCode == keybind then
  52. hold=true
  53. if enablepconsole then
  54. rconsoleprint("\npressed button")
  55. end
  56. end
  57. end)
  58.  
  59. game:GetService("UserInputService").InputEnded:connect(function(input)
  60. if input.KeyCode == keybind then
  61. hold=false
  62. if enablepconsole then
  63. rconsoleprint("\nreleased button")
  64. end
  65. end
  66. end)
  67.  
  68. game:GetService("RunService").RenderStepped:connect(function()
  69. if hold then
  70. if getnearest() then
  71. local vector, onScreen = workspace.CurrentCamera:WorldToScreenPoint(getnearest().Character.Head.Position)
  72. local dist = (Vector2.new(vector.X, vector.Y) - Vector2.new(mouse.X,mouse.Y)).Magnitude
  73. local magnitudeX = mouse.X - vector.X
  74. local magnitudeY = mouse.Y - vector.Y
  75. mousemoverel(-magnitudeX*0.5,-magnitudeY*0.5)
  76. if enablepconsole then
  77. rconsoleprint("\nmoved "..math.floor(magnitudeX)+magnitudeX-math.floor(magnitudeX).." "..math.floor(magnitudeY)+magnitudeY-math.floor(magnitudeY).." to "..getnearest().Character.Name)
  78. end
  79. wait(0.01)
  80. end
  81. end
  82. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement