This CFrame script isn't working correctly

So I found this script that makes a part follow nodes with CFrame, and it works great, except for one thing. When it comes back to the first node, it teleports to like the 90th node for no reason.

I’ve tried changing some of the code and moving the nodes around, but got nothing. I couldn’t find any similar topics on this. I should also note that this script isn’t mine, as I have no clue of how to write something like this. I’m relatively new to scripting, and this isn’t exactly a cakewalk.

I’m sure its a simple fix, but for some reason it isn’t making sense. If anyone could help, that’d be great. Thanks, stay healthy.

So, you didn’t make it yourself?

You also haven’t answered all the questions which are required for these kind of posts.

What solutions have you tried so far?

No, I didn’t make it. Also, I’ve tried moving the nodes around and messing with some of the code but nothing happened.