
1.2k Views
485 Executions
Open Source Lock On
Universal Script 📌
TruthfulJubiFirst script
7 months ago
Please login to perform these actions:Does it work?
No reports yetNo reports yet. Tried it? Be the first to say.
Also noticed:
Description
lock on, that's it really.
--improved lock on
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 closestPlayer = nil
local shortestDistance = math.huge
for _, player in pairs(Players:GetPlayers()) do
if player ~= localPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
local character = player.Character
local torso = character:FindFirstChild("HumanoidRootPart")
local screenPos = workspace.CurrentCamera:WorldToScreenPoint(torso.Position)
local mousePos = Vector2.new(mouse.X, mouse.Y)
local distance = (mousePos - Vector2.new(screenPos.X, screenPos.Y)).Magnitude
if distance < shortestDistance then
shortestDistance = distance
closestPlayer = player
end
end
end
return closestPlayer
end
local function lockOntoPlayer()
local closestPlayer = getClosestPlayer()
if closestPlayer and closestPlayer.Character then
local torso = closestPlayer.Character:FindFirstChild("HumanoidRootPart")
if torso then
mouse.TargetFilter = torso
lockedPlayer = closestPlayer









tuffy