I'm trying to find the nearest player or NPC within 50 studs and it finds all players but for some reason when I add code that checks if the player found isn't the local player it returns nothing.
local player = game.Players.LocalPlayer
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
if player:DistanceFromCharacter(v.Head.Position) < 50 then
if not player.Name == v.Name then
print("Close player found that isn't local player!")
end
end
end
end

3 comments
Just tested, It will work.
You are overcomplicating stuff, check the accepted answer.
This would run throughout other scripts, this would help out a whole lot later on when you have so many other scripts for something you only needed 2 for