Make the keybind for lockon when u press e it'll lock on to the nearest humanoid.


```
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")

-- Configuration
local ROTATION_SPEED = 0.1  -- Smooth rotation speed
local TRACKED_MODEL = nil    -- Currently tracked model
local ESP_BILLBOARD = nil    -- Reference to the ESP BillboardGui

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

-- Function to handle selecting/deselecting a target
local function toggleTarget(target)
    if TRACKED_MODEL == target then
        -- Deselect if the same target is clicked again
        TRACKED_MODEL = nil
        if ESP_BILLBOARD then
            ESP_BILLBOARD:Destroy()
            ESP_BILLBOARD = nil
        end
    else
        -- Select the new target
        TRACKED_MODEL = target
        
        -- Remove existing ESP if any
        if ESP_BILLBOARD then
            ESP_BILLBOARD:Destroy()
            ESP_BILLBOARD = nil
        end
        
        -- Create ESP for the newly selected target
        local targetHead = target:FindFirstChild("Head")
        if targetHead then
            ESP_BILLBOARD = Instance.new("BillboardGui")
            ESP_BILLBOARD.Adornee = targetHead
            ESP_BILLBOARD.Size = UDim2.new(0, 100, 0, 50)
            ESP_BILLBOARD.StudsOffset = Vector3.new(0, 2, 0)
            ESP_BILLBOARD.AlwaysOnTop = true
            ESP_BILLBOARD.Name = "TargetESP"
            
            local textLabel = Instance.new("TextLabel")
            textLabel.Size = UDim2.new(1, 0, 1, 0)
            textLabel.Text = "Targeted"
            textLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
            textLabel.BackgroundTransparency = 1
            textLabel.TextStrokeTransparency = 0.8
            textLabel.Parent = ESP_BILLBOARD
            
            ESP_BILLBOARD.Parent = player.PlayerGui
        end
    end
end

-- Function to smoothly face the target's direction
local function smoothFaceTarget(target)
    if target and target:FindFirstChild("HumanoidRootPart") then
        local targetHumanoidRootPart = target.HumanoidRootPart
        local targetPosition = Vector3.new(
            targetHumanoidRootPart.Position.X,
            humanoidRootPart.Position.Y,
            targetHumanoidRootPart.Position.Z
        )
        local targetCFrame = CFrame.lookAt(humanoidRootPart.Position, targetPosition)
        
        -- Smoothly interpolate the humanoid's CFrame towards the target
        humanoidRootPart.CFrame = humanoidRootPart.CFrame:Lerp(targetCFrame, ROTATION_SPEED)
    end
end

-- Listen for mouse clicks to select/deselect targets
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        local mouse = player:GetMouse()
        local target = mouse.Target
        
        if target then
            -- Traverse up the hierarchy to find the model with a Humanoid
            local targetModel = target:FindFirstAncestorWhichIsA("Model")
            if targetModel and targetModel:FindFirstChild("Humanoid") then
                toggleTarget(targetModel)
            end
        end
    end
end)

-- Ensure the script continues working when the character respawns
player.CharacterAdded:Connect(function(newCharacter)
    character = newCharacter
    humanoidRootPart = newCharacter:WaitForChild("HumanoidRootPart")
    
    -- Clean up any existing ESP when the character respawns
    if ESP_BILLBOARD then
        ESP_BILLBOARD:Destroy()
        ESP_BILLBOARD = nil
    end
    TRACKED_MODEL = nil
end)

-- RunService to update the face tracking smoothly
RunService.RenderStepped:Connect(function()
    if TRACKED_MODEL then
        smoothFaceTarget(TRACKED_MODEL)
    end
end)