function NULL_Spline:getNearestTime(cframe)
local t = 0
local cf2 = CFrame.identity
local lowest = math.huge
for ct=0,1,0.01 do
local cf = self:getPoint(ct)
local distance = dis(cframe,cf)
if distance < lowest then
lowest = distance
t = ct
cf2 = cf
end
end
return t,cf2
end
“dis() module”
return function(cf,cf2)
local axis,theta = cf:ToAxisAngle()
local axis2,theta2 = cf2:ToAxisAngle()
local da,db = (cf.Position-cf2.Position).Magnitude,((axis*theta)-(axis2*theta2)).Magnitude
return da+db, da, db
end