You don’t actually have to have a script with any kind of loop in it.
Here’s an example place I put together, with a ‘circular’ track and 2 carriages connected by a RodConstraint.
The carriages have 4 wheels with HingeConstraints in them, as well as 2 axles below the track with HIngeConstraints, and 2 wheels between the tracks to keep the carriages aligned. All HingeConstraints have the AcuatorType set to ‘None’.
Both carriages have a VectorForce in them which doesn’t require constant updating with a script. You can put a script in to change the X value of the script to make the train faster or slower, but I kept it simple.
When you test the place hop on a seat and go into both VectorForces. They should have a Force of 0,-1000,0 (the Y axis value helps keep the carriages on the track.
Set the X value of both of the VectorForce.Force to around 500 and the train should start to move forward slowly. I’ve had both X Forces up to 40,000 and the carriages stay on the track! After that it starts to get stuck when the RodConstraint goes over center, or it’ll derail, but the speed is impressive, especially for the 20 degree sharp turns of the track sections.
If you open up the Collison Group Editor in the Studio Model tab you can see where I added the green axles to the Wheels group, and all the ties to the Ties group, unchecking the boxes to keep them from colliding with each other. If you click on one of the axles you’ll see in the Properties window that the CollisionGroupID is 1. If you click on one of the Ties and look in the Properties window you’ll see the tie’s CollisionGroupID number is 2. There isn’t any scripting required for this either since it’s explained in the Collision Filtering | Roblox Creator Documentation link.
Train Experiment.rbxl (39.8 KB)