Help on an infinite scroling model background

Hello, I am trying to replicate something similar to how the game: average plate gaem does it on their train map, where the train model is staying in the same position while the map is constantly loading in front and unloading in the back while staying seamless. Thank you for your time and if you need me to elaborate I gladly will.

Infinite Movement - Roblox

Video:
Loop Showcase.wmv (1.4 MB)

I left the place uncopylocked so you can mess with it. The background moves forever.

The only problem is only one part moves, not the entire model. You could adjust the code so it tweens all of the parts in a model at once.

Local script

wait(1)
local runservice = game:GetService("RunService")
local s = workspace.segments
local segmentAmount = #s:GetChildren()
local TS = game:GetService("TweenService")

local furthestSegment = s["1"]
local earliestSegment = s[tostring(segmentAmount)]

while true do
	local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false)
	local movedSegment = false
	
	
	for _, segment in pairs(s:GetChildren()) do
		local pos = CFrame.new(segment.PrimaryPart.Position.X-26.693, segment.PrimaryPart.Position.Y, segment.PrimaryPart.Position.Z)
		local segmentTween = TS:Create(segment.PrimaryPart, tweeninfo, {CFrame = pos})
		segmentTween:Play()
		segmentTween.Completed:Connect(function()
			if not movedSegment then
				if segment == furthestSegment then

					segment.PrimaryPart.CFrame = CFrame.new(earliestSegment.PrimaryPart.Position.X+26.693, earliestSegment.PrimaryPart.Position.Y, earliestSegment.PrimaryPart.Position.Z)

					earliestSegment = segment

					local newSegNumber = tonumber(segment.Name)+1
					if newSegNumber > segmentAmount then
						newSegNumber = 1
					end
					furthestSegment = s:FindFirstChild(tostring(newSegNumber))
					movedSegment = true
				end
			end
		end)
	end
	repeat task.wait() until movedSegment

end

Wow, this is exactly what I was looking for! Though, it is not uncopylocked but this is a great start for my project, thank you so much!

I uncopylocked it now.

the biggest problem is it only moves one part, a solution for that has to be made.

I made it local because when it was server there would be pauses in the movement of the blocks. Hopefully making it local has solved most of this problem.

If you have any questions feel free to ask!

@Zynfiscool
If you weld a part to the segment it travel with it. The welded part has to be unacnhored and you can also turn cancollide off.

Video:
WeldedPart.wmv (1.0 MB)

Oh wow, that is a really good solution. Thank you for figuring this out.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.