repeat wait() until game:IsLoaded() local Players = game:GetService("Players") local RunService = game:GetService("RunService") local VirtualInputManager = game:GetService("VirtualInputManager") local Camera = workspace.CurrentCamera local LocalPlayer = Players.LocalPlayer local lockEnabled = false local target = nil local targetPart = nil local isFiring = false -- GUI local gui = Instance.new("ScreenGui", game.CoreGui) gui.Name = "PerfectLockGUI" local toggleBtn = Instance.new("TextButton", gui) toggleBtn.Size = UDim2.new(0, 140, 0, 50) toggleBtn.Position = UDim2.new(0.5, -70, 0.9, 0) toggleBtn.BackgroundColor3 = Color3.fromRGB(30, 30, 30) toggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255) toggleBtn.Font = Enum.Font.GothamBold toggleBtn.TextSize = 20 toggleBtn.Text = "🔓 Lock OFF" toggleBtn.BorderSizePixel = 0 toggleBtn.Draggable = true -- Get target by center aim local function getClosestTarget() local closest, shortest = nil, math.huge for _, plr in ipairs(Players:GetPlayers()) do if plr ~= LocalPlayer and plr.Character and plr.Character:FindFirstChild("Head") then local head = plr.Character.Head local pos, onScreen = Camera:WorldToViewportPoint(head.Position) if onScreen then local screenPos = Vector2.new(pos.X, pos.Y) local center = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2) local dist = (screenPos - center).Magnitude if dist < 100 and dist < shortest then shortest = dist closest = plr end end end end return closest end local function lockCameraToPart(part, velocity) local predictionTime = 0.16 local predicted = part.Position + (velocity * predictionTime) Camera.CFrame = CFrame.new(Camera.CFrame.Position, predicted + Vector3.new(0, 0.03, 0)) end local function getRandomBodyPart(char) local parts = {"Head","UpperTorso","LowerTorso","HumanoidRootPart","LeftUpperArm","RightUpperArm","LeftLowerArm","RightLowerArm","LeftLeg","RightLeg"} local valid = {} for _, p in ipairs(parts) do if char:FindFirstChild(p) then table.insert(valid, char[p]) end end return #valid > 0 and valid[math.random(1, #valid)] or char:FindFirstChild("Head") end local function startShooting() if not isFiring then isFiring = true VirtualInputManager:SendMouseButtonEvent(0, 0, 0, true, game, 0) end end local function stopShooting() if isFiring then isFiring = false VirtualInputManager:SendMouseButtonEvent(0, 0, 0, false, game, 0) end end RunService.RenderStepped:Connect(function() if lockEnabled then if not target or not target.Character or not target.Character:FindFirstChild("HumanoidRootPart") then target = getClosestTarget() targetPart = target and getRandomBodyPart(target.Character) end if target and target.Character and targetPart then local hrp = target.Character:FindFirstChild("HumanoidRootPart") if hrp then lockCameraToPart(targetPart, hrp.Velocity) startShooting() end else stopShooting() end else target = nil targetPart = nil stopShooting() end end) toggleBtn.MouseButton1Click:Connect(function() lockEnabled = not lockEnabled toggleBtn.Text = lockEnabled and "✅ Lock ON" or "🔓 Lock OFF" if not lockEnabled then target = nil targetPart = nil stopShooting() end end)