Infinite Pattern Movement not working

Hi, I am working on changing my ui designs and I want to learn how to make this effect where the pattern moves but stays the same size.

I’ve already posted about this a long time ago but after trying the code, it didn’t work for me.

I couldn’t find anything about this pattern.

Here’s my code:

local PatternMovement = {}

function PatternMovement.MovePattern(Pattern,SecondsPerCycle)
	local RunService = game:GetService("RunService")
	local Image = Pattern
	local Distance = 0
	local secondsPerCycle = SecondsPerCycle
	local speed = 1 / secondsPerCycle
		
	Connection = nil
	Connection = RunService.RenderStepped:Connect(function(dt)
		Distance += dt * speed
		-- This is called the modulo operator and wraps the distance from 0 to 1.
		Distance = Distance % 1
		-- Subtracts 200 here so that the GUI's left edge stays off the side of the screen. You'll need to make the object larger than 1,0,1,0 to make sure it covers everything.
		Image.Position = UDim2.fromOffset(Distance * 100 - 200, 0)
	end)
end

function PatternMovement.DisconnectPatterns()
	if Connection ~= nil then
		Connection:Disconnect()
	end
end


return PatternMovement

This script was taken from the old post by the way, just made it a module.

This is what it looks like in game: https://gyazo.com/337bbc5c578bfdde356590a559ee591d

Boosting this topic for help. (charrssss)

local PatternMovement = {}

function PatternMovement.MovePattern(Pattern,SecondsPerCycle)
	local RunService = game:GetService("RunService")
	local Image = Pattern
	local Distance = 0
	local secondsPerCycle = SecondsPerCycle
	local speed = 1 / secondsPerCycle
		
	Connection = nil
	Connection = RunService.RenderStepped:Connect(function(dt)
		Distance += dt * speed
		-- This is called the modulo operator and wraps the distance from 0 to 1.
		Distance = Distance % 1
		-- Subtracts 200 here so that the GUI's left edge stays off the side of the screen. You'll need to make the object larger than 1,0,1,0 to make sure it covers everything.
		Image.Position = UDim2.fromOffset(Distance * 200 - 200, 0)
	end)
end

function PatternMovement.DisconnectPatterns()
	if Connection ~= nil then
		Connection:Disconnect()
	end
end


return PatternMovement

Try this I guess

It’s still moving off direction, I don’t think I should be changing the position in this situation

Show me please. all I did was increase a value.

https://gyazo.com/5a0283192de75da0aad2d20d783d6a01

Ooh I see. Change the Distance * 100 back then there is a “Distance” value. Maybe mess with that.

1 Like

I can’t find any solution to this, maybe this isn’t possible to make a scrolling pattern without using position.

Send me a copy of the world please. Ill mess with it and ill lyk

UI Test.rbxl (43.6 KB)

Here you go, thank you for the help.

Where is the GUI? lol I cant see it

Huh, it’s in StarterGUI of course

I do not have you showed in the Gyazo