Advertisement
_Thanh_Thy_Cute_

Be A Parkour Ninja KUNAI AIMBOT

Aug 20th, 2021
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. local players = game:GetService("Players");
  2. local runService = game:GetService("RunService");
  3. local localPlayer = players.LocalPlayer;
  4. local mouse = localPlayer:GetMouse();
  5. local dot = Vector3.new().Dot;
  6. local speed = 245; --dont change
  7. local err = 1.0E-10;
  8. local camera = workspace.CurrentCamera;
  9. local isHolding = false; do
  10. local userInputService = game:GetService("UserInputService");
  11. userInputService.InputBegan:Connect(function(key, gp)
  12. if gp then return; end
  13. if key.UserInputType == Enum.UserInputType.MouseButton2 then
  14. isHolding = true;
  15. end
  16. end);
  17. userInputService.InputEnded:Connect(function(key, gp)
  18. if gp then return; end
  19. if key.UserInputType == Enum.UserInputType.MouseButton2 then
  20. isHolding = false;
  21. end
  22. end);
  23. end
  24.  
  25. local function solveQuadratic(a, b, c)
  26. if a > -err and a < err then
  27. return -b / a;
  28. end
  29. local k = -b / (2 * a);
  30. local d = k * k - c / a;
  31. if d > -err and d < err then
  32. return;
  33. else
  34. local u = d ^ 0.5;
  35. return k + u, k - u;
  36. end
  37. end
  38. --https://playtechs.blogspot.com/2007/04/aiming-at-moving-target.html
  39. local function trajectoryWithoutGravity(origin, target, movingVelocity, projectileSpeed)
  40. local p = target - origin;
  41. local c0 = dot(movingVelocity, movingVelocity) - projectileSpeed * projectileSpeed;
  42. local c1 = 2 * dot(p, movingVelocity);
  43. local c2 = dot(p, p);
  44. local t0, t1 = solveQuadratic(c0, c1, c2);
  45. if t0 and t0 > 0 then
  46. return -origin + t0 * movingVelocity + target;
  47. end
  48. if t1 and t1 > 0 then
  49. return -origin + t1 * movingVelocity + target;
  50. end
  51. end
  52.  
  53. runService.RenderStepped:Connect(function()
  54. local max, close = 1 / 0;
  55. local plrs = players:GetPlayers();
  56. for i = 1, #plrs do
  57. local plr = plrs[i];
  58. if plr ~= localPlayer then
  59. local theirChar = plr.Character;
  60. local myChar = localPlayer.Character;
  61. if theirChar and myChar then
  62. local head = theirChar:FindFirstChild("Head");
  63. if head then
  64. local pos, onScreen = camera:WorldToScreenPoint(head.Position);
  65. if onScreen then
  66. local dist = Vector2.new(pos.X - mouse.Y, pos.Y - mouse.Y).Magnitude;
  67. if dist < max then
  68. max = dist;
  69. close = plr;
  70. end
  71. end
  72. end
  73. end
  74. end
  75. end
  76. if close then
  77. local character = localPlayer.Character;
  78. local theirCharacter = close.Character;
  79. local torso = character and character:FindFirstChild("Torso");
  80. local tool = character and character:FindFirstChildOfClass("Tool");
  81. if character and theirCharacter and torso and tool and isHolding then
  82. local head = theirCharacter:FindFirstChild("Head");
  83. local hrp = theirCharacter:FindFirstChild("HumanoidRootPart");
  84. if head and hrp then
  85. local origin = CFrame.new(torso.CFrame * Vector3.new(0, 1, -1));
  86. origin = CFrame.lookAt(origin.Position, head.Position) * CFrame.new(0, 0, 1);
  87. local v = trajectoryWithoutGravity(origin.Position, head.Position, hrp.Velocity, speed);
  88. if v then
  89. --[[local hitAnything = workspace:FindPartOnRayWithIgnoreList(Ray.new(camera.CFrame.Position, v), {localPlayer.Character, camera});
  90. if hitAnything then
  91. return;
  92. end]]
  93. camera.CFrame = CFrame.lookAt(camera.CFrame.Position, camera.CFrame.Position + v);
  94. end
  95. end
  96. end
  97. end
  98. end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement