How do I tween a train precisely on a railway

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to make my train move (specifically connecting multiple cabins and tween them on a railway)

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that the method I’m using is tweening the cframe of the cabin to the cframe
    of the rail’s segment
    It will do raycasting directly downward and if a valid rail segment is found, it will tween to the segment cframe and repeatedly doing that in order to move (However if the rail segment is not faced forward, the train will behave weirdly like moving sideways, as can be seen from the axes)

The main issue I’m having is that the cabins move very individually, they don’t connect at all and they stop moving on the railway when a turn is too tight

  1. What solutions have you tried so far?
    I did look for solutions but most of the topics people created don’t help, there’re almost no replies in them. I also went over some modules like the bezier curve trying to make the curve almost precisely like the railway itself and then tween it based on that but it proved too difficult to manipulate the curve to my liking as I make more points.