Rails Kept Generating in the Wrong Way That Arc isn't supposed to do

  • What are you attempting to achieve? (Keep it simple and clear)
    Auto-generating rails with connectors and nodes
  • What is the issue? (Keep it simple and clear - Include screenshots/videos/GIFs if possible)
    Rails Kept Generating in the Wrong Way.
    I think the arc function or arctan function, or even outside related to the script.

    Generator Code (44.1 KB)
  • What solutions have you tried so far? (Have you searched for solutions through the Roblox Wiki yet?)
    Trying to fix it without changing most of the script, but all failed.