Advertisement
scriptingtales

Aimbot for VSB Roblox

Jun 6th, 2023 (edited)
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1.     local LocalPlayer = game.Players.LocalPlayer
  2.     local mouse = LocalPlayer:GetMouse()
  3.     local camera = game.Workspace.CurrentCamera
  4.  
  5.  
  6.     local function closestplayer()
  7.         local NearestPlayerOrDummy = nil
  8.         local NearestDistance = math.huge
  9.         for _, child in pairs(workspace:GetChildren()) do
  10.             if child:FindFirstChild("Humanoid") and child.Humanoid.Health > 0 and child:FindFirstChild("Head") then  
  11.                 local Distance = (child.Head.Position - LocalPlayer.Character.Head.Position).magnitude
  12.                 if Distance < NearestDistance then
  13.                     NearestDistance = Distance
  14.                     NearestPlayerOrDummy = child
  15.                 end
  16.             end
  17.         end
  18.         return NearestPlayerOrDummy
  19.     end
  20.  
  21.     local function aimAtNearestPlayer()
  22.     local settings = {
  23.         keybind = Enum.UserInputType.MouseButton2
  24.     }
  25.  
  26.     local UIS = game:GetService("UserInputService")
  27.     local aiming = false --- this toggle will make it so we lock on to the person when we press our keybind
  28.  
  29.     UIS.InputBegan:Connect(function(inp)
  30.         if inp.UserInputType == settings.keybind then
  31.             aiming = true
  32.         end
  33.     end)
  34.  
  35.     UIS.InputEnded:Connect(function(inp)
  36.         if inp.UserInputType == settings.keybind then ---- when we stop pressing the keybind it would unlock off the player
  37.             aiming = false
  38.         end
  39.     end)
  40.  
  41.     game:GetService("RunService").RenderStepped:Connect(function()
  42.         if aiming then
  43.             camera.CFrame = CFrame.new(camera.CFrame.Position,closestplayer().Character.Head.Position) -- locks into the HEAD
  44.         end
  45.     end)
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement