How would I go by this? using magnitude of course I tried already and It just keeps returning nil, here is my code.
function lib.GetClosestLimb(r, what)
local range = r
local limbs = {}
local position = plr.Character.PrimaryPart.Position
position += plr.Character.PrimaryPart.CFrame.LookVector * range/2
for i, limb in ipairs(what:GetChildren()) do
if (limb.Parent.PrimaryPart.Position - position).magnitude > range/2 then continue end
table.insert(limbs, limb)
end
return limbs
end