Infinite scrolling background is stuttering

I’ve made a script for a friend who wanted to know how to make an infinitely scrolling frame based on the solution in this topic.

However when I try to size the image up the scroll doesn’t work the same and causes stuttering. I think I’ve misunderstood something about sizing the image up and would like to clear things up.

Here is the code I’m using. The comments were for my friend to explain what everything is doing, but if something is wrong then please tell me.

local tweenService = game:GetService("TweenService")
local image = script.Parent

local goal = {}
goal.Position = UDim2.new(-1,0,-1,0)  -- describes the position the image would be at if it went to the left by half its full length once (1 is half of 2, which is the size of the image) (scale describes the image's size in relation to it's parent. when its outside a frame its in relation to the player's screen)
-- this would be the same as doing something like UDim2.new(0,-2*image.Parent.Size.X,0,0). difference is that in the offset part we offset the image by the number, but with scale we just tell it to use the respective size of the object's parent itself (eg xScale is object's parent's x size, yScale is object's parent's y size)

local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,-1,false,0)
-- takes 2 seconds, easing style is linear but it doesnt have to be you can test the other styles, idk what direction does, -1 makes it repeat infinitely, false makes it so it doesnt go back to its original spot on completion, and 0 makes it so theres no delay between repeats

local tween = tweenService:Create(image,tweenInfo,goal)

tween:Play()
-- playing the tween just once, and since repeat is -1 it repeats infinitely, creating an infinite scroll effect

Video of the scroll working while small; Scale is (2,0,2,0):


Image size while small:
image

Video of scroll stuttering when big; Scale is (4,0,4,0):


Image size when sized up:
image

For the image I am using the Tile option and setting TileSize to 0.1 in both cases. I have tried sizing the Tiles up too but it resulted in the same stuttering effect. What am I doing wrong?

I think because the image is four times the size, you might have to move it four times the distance for it to align properly. Try basing the Udim2 values off of the scale you have set.

1 Like

I thought I’d already tried that before, so I can’t believe I overlooked this. Thank you.

Setting the goal UDim2 to (-4,0,-4,0) did not work, but setting it to (-2,0,-2,0) did.
Makes sense as the image would have to move only halfway before resetting in order to make it look continuous, so it has to be set to half the size.

1 Like

I am having a similar problem, what size is your original image?

I’m not sure what the size was as I was using a friend’s image, but I do know that it was a small square tileable image.
image
After this I just did what I mentioned in the original post by changing the ImageLabel’s ScaleType to Tile, adjusting the TileSize and then just scaling the ImageLabel up to be a large square.

I’ll tell you later once I find out what size the tile image was.

Sorry if this doesn’t help.

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