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:
Video of scroll stuttering when big; Scale is (4,0,4,0):
Image size when sized up:
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?