Universal Script 📌
6.2k Views
28 Executions

Open Source GetClosestPlayer

Universal Script 📌
CMDS
CMDSPublished 10
3 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

Get closest player thingy

View Raw
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



Comments

0
Log in to join the conversation. Login
No comments yet. Be the first!

Tags

More universal scripts

See all
Universal Script 📌
6.1k
17.8k
Bumped 3 hours ago
Key System
Universal Script 📌
532.8k
336.7k
Bumped 5 hours ago
Script hub
2.6k
2.2k
Bumped 6 hours ago
Key System
Universal Script 📌
542
38
Approved 6 hours ago