Soo i’m wan’t to script a train, or simple part that follows curved path , i tried using a few parts in folder and in pairs loop but it doesn’t work good, please help
2 Likes
You can try to use TweenService or some sort of BodyMover if you also want players to move on it (although it’s more complicated).
Add a local script or server script and paste this inside:
--//Services
local TweenService = game:GetService("TweenService")
--//Variables
local Nodes = workspace.Nodes
local Train = workspace.Train
--//Controls
local Speed = 40
--//Functions
while Train:IsDescendantOf(workspace) do
for i, node in ipairs(Nodes:GetChildren()) do
local distance = (node.Position - Train.PrimaryPart.Position).Magnitude
local movementTween = TweenService:Create(Train.PrimaryPart, TweenInfo.new(distance/Speed, Enum.EasingStyle.Linear))
movementTween:Play()
movementTween.Completed:Wait()
end
end
Make a new folder called Nodes and put all your points you want the train to go to, and make sure to reference your train.
5 Likes