so, im trying to make my npc find only the closest part in a pair, but instead it gets all of the parts and goes for the first one, is there a way around it?
function FindJob() local DistMin = 500 for _,v in pairs(game.Workspace.Waypoints.Trabalho:GetChildren()) do local Pos2 = v.Position local dist = (Pos - Pos2).magnitude if dist <= DistMin then destination = Pos2 followPath(destination) print(destination) end end end