I’m trying to connect all points with their next point in table but it gives me wrong magnitude and even if i created my own function for magnitude but it’s still returns me same numbers and it don’t makes any sense

Also CFrames are not working like they supposed to as you can see on the picture
why?

That is not right at all.
First off is there any reason why you flip the sign while negative.
Second off, you cant slip up the equation into multiple sqrt roots, that breaks algebra.

The correct way is explained above using the Roblox method for it, or if you want to make your own function then you can just do…

function magnitude(a,b)
local o = a.x - b.x
local o2 = a.y - b.y
local o3 = a.z - b.z
return math.sqrt(o*o+o2*o2+o3*o3)
end

That looks like it is connecting points correctly, just the wrong points. Which makes sense, since you’re using the index of a table points as your angle.