Help on making infinite roads

Basically I want to make an infinite road by adding the roads repeatedly as a straight line, but I don’t know how to move the roads by CFrame.

image

Script:

local folder = game.ServerStorage.Folder
local pathIn = 0

for i = 1,10 do
	local part = folder.Path:Clone()
	if pathIn > 1 then
		local zOfLastPath = workspace["Path".. pathIn].Road.Position.Z
		pathIn += 1
		part.Name = "Path"..pathIn
		part.Parent = workspace
		part:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,0,zOfLastPath))) -- problem is right here
	else
		pathIn += 1
		part.Parent = workspace
		part.Name = "Path"..pathIn
	end
end 
1 Like
local RoadModel = script.Road


--for i = 1, 10 do
--	wait()
--	local Clone = RoadModel:Clone()
--	Clone:SetPrimaryPartCFrame(RoadModel.PrimaryPart.CFrame + Vector3.new(RoadModel.PrimaryPart.Size.X*i, 0, 0))
--	Clone.Parent = workspace
--end


local Index = 0
while wait(1) do
	Index += 1
	local Clone = RoadModel:Clone()
	Clone:SetPrimaryPartCFrame(RoadModel.PrimaryPart.CFrame + Vector3.new(RoadModel.PrimaryPart.Size.X*Index, 0, 0))
	Clone.Parent = workspace
end

Road.rbxl (23.4 KB)

3 Likes