Train moving on Server with CFrame Lagging

I would do that but lerp will not work for me since i am using a custom interpolation function for the curves which will not work with that.

I now am telling the client which part of the rail the train is on, and then the client runs the interpolation on its own copy of the train. This solution has worked for me, but i have now run into 2 more problems.

The client runs the interpolation every RenderStepped, but when it has completed on that section of rail, it has to wait until the server changes the RailLocation of the train, which is a value i have made to tell the train what seciton of track it is on. The server doesn’t know how fast the RenderStepped is going, and it may be different for every client, if im correct. Is this the wrong way to go about it?

Now also the player still can’t interact with the train, even though its cframe is being changed on the client’s side. Should i weld all the train’s parts to the PrimaryPart, and then just set the CFrame of the PrimaryPart of the train?

Ok. I have fixed the laggy CFrame problem now.

The only problem left is to do with physical interactions with the trains. The player can’t stand on the train when it moved, which is the only real physical interaction that i am worried about. Is there any way to allow the player to still interact with the train even though i am using CFrame to move it?

You’d have to do some math in regards to that. I’m not to sure what the math will look like but You have to declare your players position relative to the position of car. and increase player cframe based on the train cframe and any input movement u decide to incorporate.

If you want to have real-time physics interaction without having to write your own physics interaction/collision code, I would just use BodyMovers instead of individually CFraming.

1 Like

badcc explains how his Jailbreak train works, allowing you to stand on top of the train.

1 Like

You could also update the Velocity property of any part of the train you want players to stand on, just figure out how fast it’s going each frame and update it.

1 Like