Universal Script 📌
53.8k Views
4.6k Executions

Universal Lock On

Universal Script 📌
yomanisaac
yomanisaac1M views
2 years ago
Get an executor
Please login to perform these actions:

Does it work?

No reports yet

No reports yet. Tried it? Be the first to say.

Also noticed:

Description

Made by Yomanisaac Press C to lock on to player

Updates

  1. Script edited: Create script

View Raw
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
            targetLock = true


Comments

4
Log in to join the conversation. Login
Akyta's profile picture
Akyta6 months ago

i have some questions about this script

1
slightyeffective's profile picture
slightyeffective6 months ago

i made an account just to like this script, its amazing thank you.

1
yomanisaac's profile picture
yomanisaacUploader1 year ago

there was no old version

1
traxtay's profile picture
traxtay2 years ago

i loved the old version with one target only please bring back the version with one target only i need it for forsaken

1

More universal scripts

See all
Script hub
178.8k
1.7M
Bumped 3 hours ago
Key System
Universal Script 📌
9.1k
31.5k
Bumped 4 hours ago
Script hub
49.8k
12.3k
Bumped 5 hours ago
Key System
Paid
Script hub
5.5M
1.1M
Bumped 9 hours ago
Key System
Script hub
20.6k
4.0k
Bumped 10 hours ago
Key System
Paid
Universal Script 📌
730
209
Approved 15 hours ago
Universal Script 📌
634
2.5k
Approved 16 hours ago
Universal Script 📌
595
589
Approved 16 hours ago