
KeylessUniversal

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local cursorLocked = false
local connection
-- Create and set up the GUI
local gui = Instance.new("ScreenGui")
local textLabel = Instance.new("TextLabel")
gui.Name = "CursorLockGui"
gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
textLabel.Name = "LockStatusLabel"
textLabel.Parent = gui
textLabel.Text = "Cursor Unlocked"
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.Position = UDim2.new(0.5, -100, 0, 0)
textLabel.TextScaled = true
textLabel.BackgroundTransparency = 0.5
textLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
textLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
textLabel.Visible = true
-- Function to find the closest player's head
local function findClosestPlayerHead()
local closestPlayer = nil
local closestDistance = math.huge
for _, player in pairs(Players:GetPlayers()) do
if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild("Head") then
local head = player.Character.Head
local distance = (LocalPlayer.Character.Head.Position - head.Position).Magnitude
if distance < closestDistance then
closestDistance = distance
closestPlayer = head
end
end
end
return closestPlayer
end
-- Function to lock the cursor to the closest player's head
local function lockCursorToClosestHead()
local closestHead = findClosestPlayerHead()
if closestHead then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
connection = RunService.RenderStepped:Connect(function()
local camera = workspace.CurrentCamera
camera.CFrame = CFrame.new(camera.CFrame.Position, closestHead.Position)
end)
textLabel.Text = "Cursor Locked"
end
end
-- Function to unlock the cursor
local function unlockCursor()
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
if connection then
connection:Disconnect()
connection = nil
end
textLabel.Text = "Cursor Unlocked"
end
-- Function to handle mouse button press
local function onMousePress(input, gameProcessedEvent)
if not gameProcessedEvent then
if input.UserInputType == Enum.UserInputType.MouseButton2 then
if cursorLocked then
unlockCursor()
else
lockCursorToClosestHead()
end
cursorLocked = not cursorLocked
end
end
end
UserInputService.InputBegan:Connect(onMousePress)
![[KEYLESS] Moondiety Script | 17+ supported Games](https://scriptblox.com/images/sb/0-1753093706828.png)


How do I activate it
Right CLick
yo this one works you right click on mouse to lock on to player and shoot i tested it in a first person shooter
Thanks for your great feedback marv shout i carry this script on maybe a GUI?
@maxmaster3602 yeah you could put it on a gui
works (Supports) solara :D