This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Define the maximum distance to consider for finding the closest player | |
local maxDistance = 50 -- Adjust as needed | |
-- Function to find the closest player within the specified distance | |
local function findClosestPlayer() | |
local closestPlayer = nil | |
local closestDistance = math.huge -- Initialize with a very large number | |
for _, player in ipairs(game.Players:GetPlayers()) do | |
-- Ensure the player is not yourself and their character exists |