-- aimbot (continuous lock while RMB held, locks when head enters FOV) local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local localPlayer = Players.LocalPlayer local camera = workspace.CurrentCamera -- ========================================== -- CONFIGURATION -- ========================================== local LOCK_RADIUS = 150 -- Screen radius size (in pixels) from the center local TARGET_PART = "Head" -- Component to lock onto ("Head" or "HumanoidRootPart") local MAX_DISTANCE = 500 -- Maximum distance (in studs) allowed to lock on local isTrackingActive = false local currentTarget = nil -- ========================================== -- DYNAMIC UI GENERATION -- ========================================== local screenGui = Instance.new("ScreenGui") screenGui.Name = "InstantLockGui" screenGui.ResetOnSpawn = false screenGui.Parent = localPlayer:WaitForChild("PlayerGui") -- Center visual circle frame local fovCircle = Instance.new("Frame") fovCircle.Name = "FOVCircle" fovCircle.AnchorPoint = Vector2.new(0.5, 0.5) fovCircle.Position = UDim2.new(0.5, 0, 0.5, 0) fovCircle.Size = UDim2.new(0, LOCK_RADIUS * 2, 0, LOCK_RADIUS * 2) fovCircle.BackgroundTransparency = 1 fovCircle.Parent = screenGui -- Make the frame a perfect circle shape local uiCorner = Instance.new("UICorner") uiCorner.CornerRadius = UDim.new(1, 0) uiCorner.Parent = fovCircle -- Visual boundary line configuration local uiStroke = Instance.new("UIStroke") uiStroke.Thickness = 2 uiStroke.Color = Color3.fromRGB(255, 0, 0) -- Bold red circle uiStroke.Transparency = 0.3 uiStroke.Parent = fovCircle -- ========================================== -- TARGET ACQUISITION LOGIC -- ========================================== local function findTargetInRadius() local screenCenter = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2) local closestTarget = nil local shortestDistance = LOCK_RADIUS -- Iterate through players in the current game instance for _, player in ipairs(Players:GetPlayers()) do if player ~= localPlayer and player.Character then local targetPart = player.Character:FindFirstChild(TARGET_PART) local humanoid = player.Character:FindFirstChildOfClass("Humanoid") local localRoot = localPlayer.Character and localPlayer.Character:FindFirstChild("HumanoidRootPart") -- Ensure target is valid, alive, and within maximum range if targetPart and humanoid and humanoid.Health > 0 and localRoot then local distanceBetween = (targetPart.Position - localRoot.Position).Magnitude if distanceBetween <= MAX_DISTANCE then -- Project target's 3D coordinate onto the 2D viewport screen area local screenPos, onScreen = camera:WorldToViewportPoint(targetPart.Position) if onScreen then local screenDistance = (screenCenter - Vector2.new(screenPos.X, screenPos.Y)).Magnitude -- Isolate the closest player within our specified boundary limits if screenDistance < shortestDistance then shortestDistance = screenDistance closestTarget = targetPart end end end end end end return closestTarget end -- ========================================== -- INPUT TRACKING & PERSISTENCE -- ========================================== local function isRightClick(input) return input.UserInputType == Enum.UserInputType.MouseButton2 end UserInputService.InputBegan:Connect(function(input, processed) -- Do not activate tracking if the player is typing inside game chat or UI components if processed then return end if isRightClick(input) then isTrackingActive = true -- Don't lock immediately on press; let RenderStepped handle it currentTarget = nil end end) UserInputService.InputEnded:Connect(function(input) if isRightClick(input) then isTrackingActive = false currentTarget = nil end end) -- ========================================== -- INSTANT RENDERING LAYER (PER FRAME) -- ========================================== RunService.RenderStepped:Connect(function() if isTrackingActive then -- If no target or current target is invalid, try to find a new one in FOV if not currentTarget or not currentTarget.Parent then currentTarget = findTargetInRadius() else -- We have a target: keep it as long as it's valid and in range local character = currentTarget.Parent local humanoid = character and character:FindFirstChildOfClass("Humanoid") local localRoot = localPlayer.Character and localPlayer.Character:FindFirstChild("HumanoidRootPart") if not humanoid or humanoid.Health <= 0 or not localRoot then currentTarget = nil else local distanceBetween = (currentTarget.Position - localRoot.Position).Magnitude if distanceBetween > MAX_DISTANCE then currentTarget = nil end -- If they go behind a wall or out of FOV, we STILL keep lock until dead/too far -- (matches your original behavior, just now it locks when they enter FOV) end end -- Apply lock if we have a valid target if currentTarget and currentTarget.Parent then local character = currentTarget.Parent local humanoid = character and character:FindFirstChildOfClass("Humanoid") local localRoot = localPlayer.Character and localPlayer.Character:FindFirstChild("HumanoidRootPart") if humanoid and humanoid.Health > 0 and localRoot then local distanceBetween = (currentTarget.Position - localRoot.Position).Magnitude if distanceBetween <= MAX_DISTANCE then local cameraPosition = camera.CFrame.Position local targetPosition = currentTarget.Position -- Direct structural transformation: removes mechanical look delay entirely camera.CFrame = CFrame.lookAt(cameraPosition, targetPosition) else currentTarget = nil end else currentTarget = nil end end else currentTarget = nil end end)