First, I would name the rail parts in order of how they are placed (1 being the start). Then, I would give each rollercoaster segment an invisible PrimaryPart (that is located where the segment meets the rails), and then also name the rollercoaster segments from 1 to 4 (1 being the furthest back & 4 being the furthest forward). After this, you can CFrame each segment with this method to move it smoothly between rail parts. With all this in mind, something like this as an outline could help get you started:
local function StartCoaster(Coaster,RailModel)
local Rails = RailModel:GetChildren()
table.sort(Rails,function(a,b)
return tonumber(a.Name) < tonumber(b.Name)
end)
for RailNum,Rail in pairs(Rails) do
for _,Segment in pairs(Coaster:GetChildren()) do
local GoalRail = Rails[RailNum + tonumber(Segment.Name)]
TweenModel(Segment, GoalRail.CFrame)
end
wait(TweenTime)
end
end
StartCoaster(workspace.Coaster, workspace.RailParts)
Inside this function, it finds the next rail for each segment (segment number + RailNum) and tweens that segment to the desired rail. As RailNum increments, the coaster advances along the rail. This isn't tested and probably has bugs, but it should help as an outline for your solution.
1 comment
This is not a optimal suggestion, but remember the roller coaster set that stamper tools has before they got removed? Well if you do, that's good and if not, well pull up a wiki article if you're interested. Based on the way stampers worked (inserting a model outside of the game into the game) there has to exist models of the roller coaster set somewhere. I'd suggest you try something else first.