Hey there. A friend and I are making a chill game where there’s a car and of course the moving background. I’ve attempted numerous amount of times to make it loop but I cant seem to make it look the way I want it. I want to know how I could make it look seamless and infinite so it goes on forever. Thanks for your time!
explanation drawing
crap code (server)
function MoveBackground()
local background = game:GetService("Workspace")["Background"]
local info = TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
while true do
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = background:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
background:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local tween = game:GetService("TweenService"):Create(CFrameValue, info, {Value = background:GetPrimaryPartCFrame() * CFrame.new(0, 0, 1024)})
tween:Play()
tween.Completed:Wait()
CFrameValue:Destroy()
local newBackground = background:Clone()
newBackground.Parent = game:GetService("Workspace")
newBackground:SetPrimaryPartCFrame(background["Start"].CFrame)
background:Destroy()
background = newBackground
end
end
coroutine.wrap(MoveBackground)()
video