I recently found this script that makes Roller Coasters completely coded on it's own physics, and it works great, except for one thing. Once the coaster finishes its run, it teleports to a different node on the other side of the map, instead of just starting the coaster run again. The script is here:
Functions = {}
Train=0
PosToNeg1=false
PosToNeg2=false
PosToNeg3=false
PosToNeg4=false
OPosToNeg1=false
OPosToNeg2=false
OPosToNeg3=false
OPosToNeg4=false
Coaster=script.Parent
PointsGroup=Coaster.Points
Points=Coaster.Points:GetChildren()
Speed=0
DifferenceBetweenPoints={5,5,5,5}
CurrentTrackNumber={14,11,9,6}
CurrentTrack={PointsGroup:FindFirstChild("14"),PointsGroup:FindFirstChild("11"),PointsGroup:FindFirstChild("9"),PointsGroup:FindFirstChild("6")}
PreviousTrack={PointsGroup:FindFirstChild("13"),PointsGroup:FindFirstChild("10"),PointsGroup:FindFirstChild("8"),PointsGroup:FindFirstChild("5")}
CurrentPosition={0,3,1,4}
Functions.MoveCar = function(Car)
Train=script.Parent.Train
Speed=script.Parent.Speed.Value
script.Parent.CurrentTrackNumber.Value=CurrentTrackNumber[1]
if Speed>0 then
PosToNeg1=false
if OPosToNeg1==false then
CurrentTrackNumber[1]=CurrentTrackNumber[1]+1
PreviousTrack[1]=CurrentTrack[1]
CurrentTrack[1]=PointsGroup:FindFirstChild(CurrentTrackNumber[1])
CurrentPosition[1]=CurrentPosition[1]+DifferenceBetweenPoints[1]
OPosToNeg1=true
end
if OPosToNeg2==false then
CurrentTrackNumber[2]=CurrentTrackNumber[2]+1
PreviousTrack[2]=CurrentTrack[2]
CurrentTrack[2]=PointsGroup:FindFirstChild(CurrentTrackNumber[2])
CurrentPosition[2]=CurrentPosition[2]+DifferenceBetweenPoints[2]
OPosToNeg2=true
end
if OPosToNeg3==false then
CurrentTrackNumber[3]=CurrentTrackNumber[3]+1
PreviousTrack[3]=CurrentTrack[3]
CurrentTrack[3]=PointsGroup:FindFirstChild(CurrentTrackNumber[3])
CurrentPosition[3]=CurrentPosition[3]+DifferenceBetweenPoints[3]
OPosToNeg3=true
end
if OPosToNeg4==false then
CurrentTrackNumber[4]=CurrentTrackNumber[4]+1
PreviousTrack[4]=CurrentTrack[4]
CurrentTrack[4]=PointsGroup:FindFirstChild(CurrentTrackNumber[4])
CurrentPosition[4]=CurrentPosition[4]+DifferenceBetweenPoints[4]
OPosToNeg4=true
end
DifferenceBetweenPoints[Car]=(CurrentTrack[Car].Position-PreviousTrack[Car].Position).magnitude
CurrentPosition[Car]=CurrentPosition[Car]+Speed
if CurrentPosition[Car]>=DifferenceBetweenPoints[Car] then
if CurrentTrackNumber[Car]<#Points then
CurrentTrackNumber[Car]=CurrentTrackNumber[Car]+1
PreviousTrack[Car]=CurrentTrack[Car]
CurrentTrack[Car]=PointsGroup:FindFirstChild(CurrentTrackNumber[Car])
CurrentPosition[Car]=CurrentPosition[Car]-DifferenceBetweenPoints[Car]
else
CurrentTrackNumber[Car]=1
CurrentTrack[Car]=Points[1]
PreviousTrack[Car]=Points[#Points]
CurrentPosition[Car]=1
end
end
Train:FindFirstChild("Car"..Car):SetPrimaryPartCFrame(PreviousTrack[Car].CFrame:Lerp(CurrentTrack[Car].CFrame,(CurrentPosition[Car]/DifferenceBetweenPoints[Car])))
end
end
return Functions
If anyone could help me, that would be great! I'm not very good with these kinds of things.

2 comments
I think you can place an invisible part where is the beginning of the track and then replace :SetPrimaryPartCFrame(PreviousTrack[Car].CFrame:Lerp(CurrentTrack[Car].CFrame,(CurrentPosition[Car]/DifferenceBetweenPoints[Car]))) with :SetPrimaryPartCFrame(partHere.CFrame). You can change the position of the part to see where it fits the best.
It didn't work.