Universal Script 📌
6.2k Views
32 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

Updates

  1. Script edited: Create script

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
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 📌
736
210
Approved 16 hours ago
Universal Script 📌
640
2.5k
Approved 16 hours ago