Advertisement
Steamhesaproblox

Roblox Aimbot Script

May 17th, 2025
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RBScript 2.73 KB | Gaming | 0 0
  1. local cameraToggle = false
  2. local cameraTarget = nil
  3.  
  4. -- Function to find the closest player to the center of the screen, excluding the local player
  5. local function findClosestPlayerToScreenCenter()
  6.     local playerList = game.Players:GetPlayers()
  7.     local center = Vector2.new(workspace.CurrentCamera.ViewportSize.X / 2, workspace.CurrentCamera.ViewportSize.Y / 2)
  8.     local closestPlayer = nil
  9.     local minDistance = math.huge
  10.     local localPlayer = game.Players.LocalPlayer  -- Get the local player
  11.  
  12.     for _, player in pairs(playerList) do
  13.         if player ~= localPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  14.             local screenPos, onScreen = workspace.CurrentCamera:WorldToScreenPoint(player.Character.HumanoidRootPart.Position)
  15.            
  16.             if onScreen then
  17.                 local distance = (center - Vector2.new(screenPos.X, screenPos.Y)).Magnitude
  18.                 if distance < minDistance then
  19.                     minDistance = distance
  20.                     closestPlayer = player
  21.                 end
  22.             end
  23.         end
  24.     end
  25.  
  26.     return closestPlayer
  27. end
  28.  
  29. -- Function to aim the camera at a specific player
  30. local function aimCameraAtPlayer(player)
  31.     if player and player.Character and player.Character:FindFirstChild("Head") then
  32.         local camera = game.Workspace.CurrentCamera
  33.         local targetPosition = player.Character.Head.Position
  34.         camera.CFrame = CFrame.new(camera.CFrame.Position, targetPosition)
  35.     end
  36. end
  37.  
  38. -- Function to toggle the camera aim on/off
  39. local function toggleCameraAim()
  40.     cameraToggle = not cameraToggle
  41.     if cameraToggle then
  42.         cameraTarget = findClosestPlayerToScreenCenter()
  43.         game.StarterGui:SetCore("ChatMakeSystemMessage", {
  44.             Text = "Press 'Q' to toggle the aimbot",
  45.             Color = Color3.new(1, 1, 0),  -- Yellow color
  46.             FontSize = Enum.FontSize.Size24,
  47.         })
  48.     else
  49.         cameraTarget = nil
  50.         game.StarterGui:SetCore("ChatMakeSystemMessage", {
  51.             Text = "Aimbot toggled off",
  52.             Color = Color3.new(1, 0, 0),  -- Red color
  53.             FontSize = Enum.FontSize.Size24,
  54.         })
  55.     end
  56. end
  57.  
  58. -- Connect the toggleCameraAim function to the "E" key press
  59. game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
  60.     if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.Q then
  61.         toggleCameraAim()
  62.     end
  63. end)
  64.  
  65. -- Continuously aim the camera at the closest player if the cameraToggle is on
  66. local runService = game:GetService("RunService")
  67. runService.RenderStepped:Connect(function()
  68.     if cameraToggle and cameraTarget then
  69.         aimCameraAtPlayer(cameraTarget)
  70.     end
  71. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement