How can I make players stick to moving parts?

(NOTE: I need this for UNANCHORED parts, not anchored ones. I’m so sorry for the confusion.)

I want to make it so that when a player is on a part, and that part is in motion, the player stays ontop of the part and is able to walk around and jump without changing location. Some players are already able to do this, but there are frames where they can slide and fall off. (And laggy players don’t stand a chance, either.)

How could I do this? A script that affects all parts instead of individual ones would be nice, just for simplicity.

Edit: Honestly, I feel like this should be an official feature, like something you can toggle.

2 Likes

I think your best bet is tweens.

2 Likes

I think your best option is to change the assembly linear velocity of the part as it moves. There was a very good youtube tutorial, I can’t seem to find it but basically they use a few math functions using renderstepped delta time and the change in position to then set the velocity of that part. Since the part is anchored, Roblox physics cant affect it but your player model will follow it

edit

1 Like

I need this for unanchored parts, not anchored ones. It’s so the player can stand inside of a moving vehicle.

I’m unsure what you could do, but I’ll throw some ideas your way. Maybe add a touch part, and whenever a player is on the vehicle, use a weld constraint on their primary part.

Wouldn’t that stop them from being able to walk around?

Yes, it would. You said you wanted the part to be unanchored and in motion?

Yeah. The part should be able to move around, since it’s part of a train. If a player stands on the train or in something the train is pulling, they should be able to stand and walk around without the risk of glitching and falling out onto the track.

The video posted by @SPR1NG3R should do the trick; forget about the tween service and get the train’s position or the part position that’s in motion.

@SPR1NG3R’s video is for anchored parts. The train is unanchored.

The only way to make players stick to moving parts is to use some sort of BodyMover on the part you want to move, like AlignPosition.

I’ll try that when I get the chance.

This can help you get started: (keep in mind BodyPosition is deprecated, so you may not want to use it)

have you made anything and tested this out? depending on how you are moving the train, if its unanchored then it would have linear velocity? I might be mistaken but.

1 Like

You can do some stuff with a Weld, though I haven’t tried anything yet.

I haven’t tried anything since I’ve been unable to find anything that would be easy to implement.

Welds would stop the player from moving. When on the train, I want them to be able to move around normally as if the train was idle, without glitches such as sliding off or jumping causing you to fly backwards.

You could artificially move the weld CFrame in their move direction.

1 Like

And how would I do that?

‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’

I’m not sure. It shouldn’t be too hard though, however the hard part may just be replicating it.

1 Like