Advertisement
HackerMan22333

aimbot script op

Jun 27th, 2024
1,783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. -- ctrl to aimbot
  2. -- GOOD FOR TSB TESTED IT LOL
  3. local UserInputService = game:GetService("UserInputService")
  4. local Players = game:GetService("Players")
  5. local camera = game.Workspace.CurrentCamera
  6.  
  7. local isFacingLocked = false
  8. local isTyping = false
  9. local nearestPlayer = nil
  10.  
  11. local function findNearestPlayer()
  12. local minDistance = math.huge
  13. local closestPlayer = nil
  14. local localPlayerPosition = Players.LocalPlayer.Character and Players.LocalPlayer.Character.HumanoidRootPart.Position
  15.  
  16. if not localPlayerPosition then
  17. return nil
  18. end
  19.  
  20. for _, player in pairs(Players:GetPlayers()) do
  21. if player ~= Players.LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  22. local distance = (player.Character.HumanoidRootPart.Position - localPlayerPosition).magnitude
  23. if distance < minDistance then
  24. minDistance = distance
  25. closestPlayer = player
  26. end
  27. end
  28. end
  29.  
  30. return closestPlayer
  31. end
  32.  
  33. local function faceNearestPlayer()
  34. if isFacingLocked then
  35. nearestPlayer = findNearestPlayer()
  36. if nearestPlayer then
  37. local targetPosition = nearestPlayer.Character.HumanoidRootPart.Position
  38. local lookVector = (targetPosition - camera.CFrame.Position).unit
  39. camera.CFrame = CFrame.lookAt(camera.CFrame.Position, camera.CFrame.Position + lookVector)
  40. end
  41. end
  42. end
  43.  
  44. UserInputService.InputBegan:Connect(function(input)
  45. if input.KeyCode == Enum.KeyCode.LeftAlt or input.KeyCode == Enum.KeyCode.RightAlt then
  46. isFacingLocked = not isFacingLocked
  47. if not isFacingLocked then
  48. nearestPlayer = nil
  49. end
  50. elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
  51. if isFacingLocked and not isTyping then
  52. faceNearestPlayer()
  53. end
  54. elseif input.UserInputType == Enum.UserInputType.TextBox and input.UserInputState == Enum.UserInputState.Begin then
  55. isTyping = true
  56. end
  57. end)
  58.  
  59. UserInputService.InputChanged:Connect(function(input)
  60. if input.UserInputType == Enum.UserInputType.TextBox then
  61. if input.UserInputState == Enum.UserInputState.End then
  62. isTyping = false
  63. end
  64. end
  65. end)
  66.  
  67. game:GetService("RunService").RenderStepped:Connect(function()
  68. faceNearestPlayer()
  69. end)
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement