I am trying to sort a table by lowest distance, and I get this error:
Invalid order function for sorting
this is the function:
local function GetColliding(part: BasePart)
local pos = part.Position
local inRange = workspace:GetPartBoundsInRadius(pos,self.GrabRange)
if #inRange > 0 then
table.sort(inRange,function(a: Part,b:Part)
return ((a.Position-pos).Magnitude <= (b.Position-pos).Magnitude)
end)
return inRange
end
end
