Universal Head Lock On Script
Key RequiredUniversal

Universal Head Lock On Script

Universal ScriptYoriScriptsYoriScripts 3.1K views 487 executesUpdated Nov 27, 2025
5.0/ 5(2 votes)
20100% Positive
Lua Script•72 lines (2008 chars)
-- Head Lock-On System (Client-Side)
-- Keybind: X to toggle

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()

local targetLock = false
local lockedPlayer = nil

local function getClosestPlayer()
    local closest = nil
    local shortestDist = math.huge

    for _, player in pairs(Players:GetPlayers()) do
        if player ~= LocalPlayer and player.Character then
            local head = player.Character:FindFirstChild("Head")
            if head then
                local screenPos = workspace.CurrentCamera:WorldToScreenPoint(head.Position)
                local mousePos = Vector2.new(Mouse.X, Mouse.Y)
                local distance = (mousePos - Vector2.new(screenPos.X, screenPos.Y)).Magnitude

                if distance < shortestDist then
                    shortestDist = distance
                    closest = player
                end
            end
        end
    end

    return closest
end

local function lockOn()
    local target = getClosestPlayer()
    if target and target.Character then
        local head = target.Character:FindFirstChild("Head")
        if head then
            lockedPlayer = target
            targetLock = true
        end
    end
end

local function updateLock()
    if lockedPlayer and lockedPlayer.Character then
        local head = lockedPlayer.Character:FindFirstChild("Head")
        if head then
            local cam = workspace.CurrentCamera
            cam.CFrame = CFrame.new(cam.CFrame.Position, head.Position)
        end
    end
end

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.X then
        if not targetLock then
            lockOn()
        else
            lockedPlayer = nil
            targetLock = false
        end
    end
end)

RunService.RenderStepped:Connect(function()
    if targetLock then
        updateLock()
    end
end)

Features & Information

Locks On To Players Head Works In Any Game On Roblox

Community Comments (4)

YoriScriptsYoriScriptsNov 27, 2025

Enjoy The Script!

gav1010101010gav1010101010Nov 27, 2025

works great for rivals

Replying to @gav1010101010
YoriScriptsYoriScriptsNov 27, 2025

@gav1010101010 That's nice

noah97953noah97953Mar 25, 2026

it supa great! i used it in fng with rtimpact fruit

More Scripts for Universal Scripts