Open Source GetClosestPlayer
Key RequiredUniversal

Open Source GetClosestPlayer

Universal ScriptCMDSCMDS 6.2K views 27 executesUpdated Feb 7, 2024
Unrated
00
Lua Script•17 lines (764 chars)
local ShortestDistance = math.huge
local function GetClosestPlayer()
    local ClosestPlayer
    for i, v in pairs(game.Players:GetPlayers()) do
        if v ~= game.Players.LocalPlayer and v.Character and v.Character:FindFirstChild("Humanoid") and
                v.Character.Humanoid.Health ~= 0 and
                v.Character:FindFirstChild("HumanoidRootPart") then
            local Position = Camera:WorldToViewportPoint(v.Character.PrimaryPart.Position)
            local Magnitude = (Vector2.new(Position.X, Position.Y) - Vector2.new(Mouse.X, Mouse.Y)).magnitude
            if Magnitude <= ShortestDistance then
                closestPlayer = v
                ShortestDistance = Magnitude
            end
        end
    end
    return ClosestPlayer
end

Features & Information

Get closest player thingy
#Open source

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts