Player moving off Tween Part

I have tried making a train and the train is being moved by tweening. I have a problem however, and that is that the Player wont stay on the train. I have tried many solutions from DevForums but it wont work due to how my train game works

Im at a lost. its been 2 days
Any help is appreciated :slight_smile:

5 Likes

Can we see the script you are using?

I dont have it anymore. Most of the scripts i tried dont work.

1 Like

Try using HingeConstraint and set the MaxTorque to inf. It’ll probably be able to carry players.

What do you mean? Do i hingeconstraint the player to the ground?

1 Like

You can use this code to give the part a velocity so that it moves the player with it:

lastpos = part.Position
game:GetService("RunService").Stepped:Connect(function(_, deltatime)
   local currentpos = part.Position
   local deltapos = currentpos - lastpos
   local velocity = deltapos / deltatime
   part.AssemblyLinearVelocity = velocity
   lastpos = currentpos
end)

this gives it a velocity so that the player moves on top of it. It doesn’t work too well with high speeds but I guess it could be good enough. It does have a small amount of delay with the movement of the player though.

2 Likes

Add an invisible part above the train and hingeconstraint it with the train.

Tried the velocity method before. Its abit buggy as my trains are travelling at 100sps

If you are using a Linear tween, then you can use the fact that rate = distance/time to set the train’s velocity without losing a frame.

It’d be nice if you can elaborate on how the train’s speed changes as it moves and what type of path is that it follows.