Universal Script 📌
52.6k Views
3.3k 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

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
Akyta5 months ago

i have some questions about this script

1
slightyeffective's profile picture
slightyeffective5 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
Universal Script 📌
2.7k
30.2k
Bumped 50 minutes ago
Universal Script 📌
6.1k
17.8k
Bumped 2 hours ago
Key System
Universal Script 📌
530.6k
336.7k
Bumped 3 hours ago
Script hub
2.5k
2.2k
Bumped 4 hours ago
Key System
Universal Script 📌
400
37
Approved 5 hours ago
Script hub
2.8M
661.6k
Bumped 5 hours ago
Key System

Script hub

#2 today

Verified script badgeFlow Hub | 35 Games | Updated