I have some code, which makes a object follow a path of parts. This is for a rollercoaster. I was wondering if anyone would able to help me so that:
- It moves a model instead of one part
- Anyway to make it more efficient
- Is there anyway to get all the track parts without having to manually write every one
Thanks!
local p1 = script.Parent:WaitForChild("Track1")
local p2 = script.Parent:WaitForChild("Track2")
local p3 = script.Parent:WaitForChild("Track3")
local p4 = script.Parent:WaitForChild("Track4")
local p5 = script.Parent:WaitForChild("Track5")
local rp = script.Parent.CarFront
while wait() do
for i = 0,1,.05 do
rp.CFrame = p1.CFrame:lerp(p2.CFrame,i)
wait(0.0001)
end
for i = 0,1,.05 do
rp.CFrame = p2.CFrame:lerp(p3.CFrame,i)
wait(0.0001)
end
for i = 0,1,.05 do
rp.CFrame = p3.CFrame:lerp(p4.CFrame,i)
wait(0.0001)
end
for i = 0,1,.05 do
rp.CFrame = p4.CFrame:lerp(p5.CFrame,i)
wait(0.0001)
end
for i = 0,1,.05 do
rp.CFrame = p5.CFrame:lerp(p1.CFrame,i)
wait(0.0001)
end
end
