
889 Views
79 Executions
Does it work?
No reports yetNo reports yet. Tried it? Be the first to say.
Also noticed:
Description
https://discord.gg/sw33zwSn
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
local locked = false
local target = nil
local LOCK_KEY = Enum.KeyCode.C
local TARGET_PART = "Head"
local MAX_DISTANCE = 500
local function GetTarget()
local closest = nil
local shortestDist = math.huge
for _, v in pairs(Players:GetPlayers()) do
if v ~= player and v.Character then
local char = v.Character
local humanoid = char:FindFirstChild("Humanoid")
local part = char:FindFirstChild(TARGET_PART)
if humanoid and humanoid.Health > 0 and part then
local pos, onScreen = camera:WorldToScreenPoint(part.Position)
if onScreen then
local dist = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(pos.X, pos.Y)).Magnitude
if dist < shortestDist and dist < MAX_DISTANCE then
shortestDist = dist
closest = part
end
end
end
end
end
return closest
end









Cool Works