How do i move an object in a moving object?

Hi,
I want to make a train with doors you can open like in the MadCity Tram heist. When the train moves, how can i move the doors open?

All parts of the train are welded to a PrimaryPart wich will get tweened.

I donโ€˜t want the door to get Invisible or something like that!

Please teach me how you would do it.
Thanks :smiley:

1 Like

You can use Motor6Ds.

First, create a part. Size it to 1,1,1, and position it on either the left or right side of your door. This will act as a hinge.

Next, use the Motor6D plugin. Duplicate your hinge part, and name it B. Name the other part to A. With the motor6D creator, select your door as the part to rotate, A for the motor, and B for the pivot point. This creates a motor6D.

Weld any parts part of your door to the part you selected on the first step of the plugin, and then weld A and B to your train. Turn off collisions and transparency on both A and B.

For scripting, you will have to edit the C0 property of the motor. An example is like shown:

TweenService:Create(motor, TweenInfo.new(), {C0 = motor.C0 * CFrame.new(5,0,0)}):Play()

You can play around with this property to get the offset youโ€™d like.

A video tutorial I found using the same steps:

Good luck with your train!

1 Like