I need help with making a train move


Ok so right now I have this train model which I made and it has a train system and it can move,now I need help with making a guiding system or something so that the train will follow the tracks on the ground.

1 Like

Isn’t this more for scripting support? I may be wrong. Looks great anyways!

2 Likes

This might not apply to the train, but I suggest you use a tutorial that makes an NPC move. There are a lot of those on Youtube.

1 Like

How is that helpful though I mean its a train like you said not an NPC. Just remember when making custom NPCs you need all the correctly named parts in the right places. And I honestly don’t think that someone is gonna make the trains wheels called LeftFoot lol. This is just saying how making vehcles are much different to NPCs.
P.s: Im not being rude or anything lol :slightly_smiling_face:

1 Like

I understand what you are saying, but these moving NPCs are essentially just moving models. The videos don’t show how to animate the feet or anything, just how to make it move.

1 Like

Yea I was about to edit my reply and add that lol. I mean yes I guess the roblox movement system is similar in some parts. And yes the players physical model is moving so I guess they could be applied to other objects too. :smiley:

Also im sorry if i sounded rude in my last reply. I hate it when i do things like that.

1 Like

There are several possible approaches to choose from, each with pros and cons. As others have suggested, you could handle it similarly to character movement, where the network owner is one of the clients, and that client moves the train a little bit every frame and replicates its new position out. Alternatively, you could make the server the network owner. Either way, you have to decide whether to use physics or “cframing” (setting the CFrame of the parts manually). If you choose the latter, the trick is making any characters riding the train also move. You either have to move them manually as well, which gets tricky if they need to maintain control of their individual character movement, or use other hacks like anchoring the train and setting its velocity to match the rate at which you are moving the cframe.

If you want to go the physics route, you can create an anchored “goal part” just in front of the train and connect it to the train with an AlignPosition. Then, you can move the goal part every frame and let physics pull the rest of the train. In this case, any characters riding inside should move along without extra trouble.

As far as having the train follow a track, one possibility is to create a sequence of “breadcrumb” parts (transparency=1, cancollide=false) along the track in an ordered fashion. When the train encounters one breadcrumb (via “Touched” event or simple distance-checking), it adjusts its goal to the next one.

Depending on how many trains you plan on having, network replication bandwidth can be an issue, as Roblox doesn’t give you much budget for a lot of independent parts in one place moving around at the same time (bandwidth is capped at 60kB/s).

1 Like

Take this example model and study how it works.
image
TrainChassisExample.rbxm (17,6 KB)
The green part is the driver seat, the grey part is the engine. The yellow balls are the wheels and the purple balls are gliders. Just put the chassis where it belongs (under your train bogies) and weld everything (maybe use qPerfection for welding).

Also nice train :train:

2 Likes

But the problem with this solution is when we have wagons separated with ballsocketconstraints It can derail. I also use this type of chassis but they derails a lot.

1 Like