Players falling of train

So i have a train game which uses tween service to move. And the train base has its velocity set to X number so the player wont fall of when riding the tween-ed train. However, when a player has ping higher than 400, the game freezes for them and when the ping recovers, they might glitch out of the train or just get sent backwards down the train

If the player is lagging, it is hardly predictable to figure out where they should be if the path of the train isn’t straight-forward. Additionally, physics-based trains are more favorable in these cases over TweenService, although still suffers the same length of issues with lag too…

The train travels in a straight line. though do you know any way how to prevent this cause ik alot of friends who get average 300ms and if they play my game they might glitch off. Would setting the base’s velocity on the client work and change when its moving and when its not?

I don’t think there’s much you can do about this apart from scripting a patch. The train moves on the server, which means that by the time the client recovers from their lag spike, it will have already moved. This is intended behavior. The best solution I can think of is using a custom-scripted physics solution like this one, although I’m not sure how this would work out.

If the whole point of the game is to stand on a train, then maybe moving the world around the player is more favorable. Also, like @Operatik said, physics-based trains are much much better.

The reason i switch from physics-based trains to tween trains was because the trains contain to many parts and when there are multiple trains being moved by bodyVelocity, causes them to slow down. Both have down sides. Also, phyhsic based trains kept derailing for no reason, even with Prismatic constraints

It might sound janky, but you could move the player forward forcibly if necessary, only to expose different lengths of issues. Otherwise you have to try to optimize the game if it is laggy.

You cannot fix the user’s internet. Extrapolation is tricky to deal with if you’re going to go far enough to fix that issue. :slight_smile:

Is there any way to fix this ping lag (optimized it) 100% of the parts in my game are anchored, decorations and parts unreachable to players have cancollide turned off and detail with multiple parts are unioned

I mean, if you are using TweenService, then BodyPosition with BodyGyro would work too, don’t you think? You can keep your code the same, but instead of using the Position property of the part / model, use the BodyPosition constraint. Also, you might want to Union some parts or something if it is that laggy.

Its not possible, my trains has more unions than parts already. I already unioned as many things as possible. The remaining parts cannot be union as they have a use. Therefore, i just cant use physic trains. I already used them before

I see. Well, at this point, it might be better to move the train on the client side. At least, regardless of lag spikes, the train will somewhat keep moving correctly for as long as the speed is consistent. Otherwise, you’ll have to make some calculations to rubber-band them back to what was supposed to be their position.

If I run all tween trains on the client, sinces its being tween, do you think they can all be in sync?

They would all be asynchronous by technical details. If one client lags, there will be issues.

It is hard to get them all in sync. Of course, you’ll need to have a system to correct for offsets, but client lag is inevitable, so they’ll probably never be in sync. But, even in normal Roblox, what looks like is in sync with all clients is usually not in sync completely. For as long as they looks in sync enough, it won’t be a problem. Just implement a rubber-banding system to correct for any lag issues.

Alright, Ig i will do as according to your sugestuions

Prompt them to get ethernet, lol. Fixed a huge loss of download and upload speed for me.

You should consider a physic based train like @Operatik said, but I don’t know how this would be done.