How can I make players stick to a train?

I have made a train using TweenService.

However, when a player steps on the train they just glide off. How can I make players stick to the train carriages as they move?

I know that I can use GravityController to do this, but I am unsure how exactly I can do this. Does anyone else have other methods?

4 Likes
2 Likes

After a bit of testing I found that method only works for a brief period of time before failing.

This is the place that I’m testing on if you wanna have a go:

The answer provided there is just the snippet of code he gave that makes it work. I recommend experimenting with it more as the system works quite well if set up properly. Also, I recommend you use WorldRoot | Documentation - Roblox Creator Hub instead of Ray.new

What would the rest of the code look like? What still needs to be written in order of the code to work?

oops, it’s WorldRoot:Raycast()

The system works by connecting a Heartbeat event to some code that will cast a ray and if you’re on RaftTop, it will update your position to the relative CFrame you should be at. The core of the code and math is in the heartbeat event connection, so if you take a brief look at it you should be able to extract the core pieces you need from it and piece it together in whatever your current system is for it to work.

I also apologize and would give you a detailed explanation of everything, but I’m on my phone and in the middle of an event.

1 Like

I’m sorry, but I still don’t understand how to accomplish my goal.

What do you mean by glide off? Also you could make all of the entrances a teleport to a random seat.

1 Like

It’s more of a jailbreak type train, the intention is for the player to be able to move about on the train.

Oh. Understood. Maybe change the player’s BodyVelocity to the train’s BodyVelocity when they’re on the train.

1 Like