CFrame train not moving player

I made a cframe train. However, when the player is riding on it, the player slides right off.

Heres the script

while wait() do
	engine.CFrame = engine.CFrame + Vector3.new (-1.3 * atStation.Value, 0, 0)
end

the atStation.Value is always at 1. Ignore it.
I have no idea how to use tweenService

1 Like

Yeah, im pretty sure thats just roblox physics being jank. Not a scripting problem at all.
Fortunately, roblox are actually working on something which you can view here.

From the post:

Now with that out of the way, to avoid a potential other post, this is a beta feature, publishing a game using it will result in your game not working properly.
This is currently only usable in studio (i think)

There are ways to script you way around this, but i dont think its worth scripting a fix when this is coming out sometime in the future.

If you only change the position the character won’t know that what it’s standing on has moved.

You’ll have to also update the train’s velocity, like when making a conveyor belt

do you know how to script this however

In the post they’re talking about how the new beta humanoid controller has support for keeping momentum when jumping.
Moving with a moving vehicle you are standing on already works with the current humanoid system.

1 Like

This is working as expected

The player doesn’t stay on your train because the train has no velocity, its simply having its position changed every frame. You will not get any physical reactions if you do this.

You’d want to drive the trains motion via constraints, either by diretly applying VectorForce/LinearVelocity, or actually spinning the wheels with HingeConstraints, or some other simulated system.

Or, you’d need to write code for the player (and anything else you want to have interactions with the train) to also update it’s CFrame with the train’s

3 Likes

Whats the difference between VectorForce and the LinearVelocity

VectorForce applies a constant force
LinearVelocity applies a dynamic force, to speed up or slown down an object to the given velocity (with a max of course)

But I don’t think you should use constraints to move the train since then it becomes possible to derail the train.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.