How would I get a model to follow this path?

So, I’m attempting to make a vehicle that runs basically like a Tram (except it wont be attached to a guide wire).

EDIT: Actually, if I could just get it to follow a straightline, that’d be awesome!

If you can help me or have questions, please let me know! :smiley:

Here’s a diagram I drew up to hopefully explain what I’m trying to accomplish.


2 Likes

Perhaps weld all of the items together using weld said or a weld script then just use pathfinding.

Is the vehicle on a preset path like a tram, or is it controlled by a player or something?

My buddy helped me come up with this:

P = Model:GetChildren()
for i=1, 1000 do
    for _,v in pairs(P) do
        v.CFrame = v.CFrame + Vector3.new(0,0.1,0)
    end
    wait()
end

Anyone who’s reading this, does that look right to you?

I decided making it go straight would be easier, so it just has to go straight one direction from where I set it, it isn’t controlled by anyone except for the script that starts it.

1 Like

Sure that can work if put in a loop, however it’d be better if you used something like :SetPrimaryPartCFrame or welds.

Alrighty, I’ll see if that code works, and if it doesn’t prove to me satisfactory I’ll try something else. :slight_smile:
Thanks for your replies!

Hi. I also reccomend what @EmeraldSlash said, about using SetPrimaryPartCFrame. All you have to do is create a primary part for the model. Then use :SetPrimaryPartCFrame() instead of looping through the entire model to move it, what @Noxility suggested.

EDIT: Not what Noxility suggested lol! What your friend came up with :joy:

2 Likes

I’ll try and set up both and overview their performance. Thanks!

Thank you @EmeraldSlash and @xuefei123, :SetPrimaryPartCFrame() works tons better!

2 Likes

no no no no no
bad
Never use SetPrimaryPartCFrame

Use WeldConstraints and tween the main part or something

:+1:

1 Like

It’ll only be moving for about 5 minutes, 5 minutes shouldn’t make it get off by much if any at all.

But then the “Tram” will be used again and again all day in the same server. You’ll start running into problems faster than you think.

TweenService would be a lot easier to deal with something like this, if it is just a background thing. if you want players to be able to ride it then you are going to have to work with constraints/body movers to get everything working nicely

1 Like

All this place is going to be is a showcase, it’ll probably just be one player, so I don’t need to worry about it running all day and breaking since it’ll only run once per server for about 5 minutes.

SetPrimaryPartCFrame is not bad in itself, the only problem arises when you’re doing floating point operations with a cumulative error. In the case of moving a part in a straight line from A to B this is much more negligable of an effect than when rotating the model again and again using the outcome of the previous rotation (relative) rather than a set of new coordinates (absolute).

1 Like