Well, sort of but there would be no use of it I guess since you’re lerping and doing bodyvelocity.
Alright, hold on i’ll write out a script for you to use.
here i trying to use cframe
i think this is bad idea, bc i have welded things
No lerping is a very good idea, give me a second.
Okay so basically, here’s how it goes:
while true do
for i = 0, 1, .0001 do
q.Parent.CFrame = q.Parent.CFrame:Lerp(q.Parent.CFrame * CFrame.new(0,0,1), i)
task.wait(0.001)
end
task.wait(.1)
end
I’m assuming q.Parent is the main part of the train, make sure “q” is also anchored. But only q, this is so that players who come infront of the train won’t stop it from moving and the train will remain functional.
Since we’re moving q.Parent’s CFrame, if like you said the other parts have been welded to the train the rest of the parts will also move along with the train. Proof is on the documentation which states this:
I assume in the video you have showed me you’re just moving the Position which is a vector3, and as the documentation says the rest of the welded parts wouldn’t move.
But in this code sample we’re lerping the CFrames, so the rest of the welded parts also move along with it.
I’ve also tried testing this on studio myself and this has worked and moved the rest of the parts along, and it has created a smooth transition.
Also make sure you use a while loop like I have instead of runservice because while loops respect for loop and yielding nature.
A nice bonus is that the train actually accelerates instead of staying at a constant speed if that’s what you want.
By the way if you have any turns on the tracks instead of going in a straight line, then you will still need to use CFrames:
workspace.Part1.CFrame = workspace.Part1.CFrame * CFrame.Angles(0,90,0)
This is just some sample code but what would happen is the other parts welded to this part would also rotate with it.
If you just used a vector3 such as .Orientation, the other parts would not do this.
I tried as you said, but the problem is that q.parent is moving. thanks to the cframe, all the attached parts actually move, but firstly it’s not convenient, because… there are turns and the size of the script will immediately increase, since the turns are not the same everywhere and they are of different radii, and I also said earlier that I have doors on the prismatic and they do not travel with the train(im using translator)
I think it will better to use bodyvelocity, because i have prismatic constraint doors and they not moving.
Yes, so when there are turns you can check when these are and change the angle of the CFrame accordingly:
Secondly,
I assume what you mean is when the doors open the sliding looks strange, so what you can do instead is use vector3s on the doors so that the rest of the train stays the same orientation and position:
This is just some sample code for you to get an idea from.
workspace.Part1.Orientation = workspace.Part1.Orientation:Lerp(workspace.Part1.Orientation + Vector3.new(0,90,0), 1)
Are the doors welded to the train or no?
they not welded just holding by the prismatic constraints
Yes so you need to weld these doors to the train aswell, otherwise they won’t move.
If i weld doors they cant open
You can open them in different ways, you can use tweens instead for opening doors and stuff.
the idea is really good, but they are specially supported by hings and prismatics and are not anchored, so that when closing they can shake a little, as in reality, if I remove the prismatic and hinge and put them on a tween, but this realism will disappear, and even more so I specifically use Prismatic so that it can accidentally pinch a player for RP.
How about lerp bodyvelocity? -–-
Would not be a good idea since it’s still using roblox physics, there would be no point in lerping. Lerping + bodyvelocity might be even worse actually.
Prismatics actually are worse than tweens for quite a few reasons:
-
Can be abused by exploiters and cause serious damage
-
Using prismatic constraints can cause more lag
The only benefit of prismatics is that it’s realistic, most people use prismatics on elevators because they want to make it realistic with weight being added to the elevator. But you’re using a sliding door, so the weight would be added to that door but it would be unnecessary as that is not an intended effect. So really there is no benefit of using prismatics here.
Tweens will remain functional because they dont respect roblox physics, even if its slightly less realistic.
I’m pretty sure jailbreak uses tweens for the doors and lerp their train aswell, and it’s a big game so I would recommend doing the same.
Back in 2018 when the train came out in jailbreak, it had major issues as it was very buggy and what not. This was because it relied on roblox physics
But I’m pretty sure the programmer of jailbreak started to use lerping and tweens for the doors and stopped relying on roblox physics and the train became less buggy.