TextLabel Slide not constant with TweenService

Hello everyone,

I am currently in the process of creating a matrix display for trains and buses. My idea was to use a ServerScript in the workspace and the TweenService to animate the position and the AnchorPoint of the text.

Here is my code for the animation:

local text = script.Parent.TextLabel

local TweenService = game:GetService("TweenService")

local info1 = TweenInfo.new(text.AbsoluteSize.X / 175,Enum.EasingStyle.Linear)
local info2 = TweenInfo.new(text.AbsoluteSize.X / 400,Enum.EasingStyle.Linear)
local position1 = UDim2.new(0,0,0,0)
local positionOrigin = UDim2.new(1,0,0,0)
local anchorpoint1 = Vector2.new(1,0)
local anchorpointOrigin = Vector2.new(0,0)

while true do
	text.Position = positionOrigin
	text.AnchorPoint = anchorpointOrigin
	wait(1)
	local tween1 = TweenService:Create(text,info2,{Position = position1})
	tween1:Play()
	tween1.Completed:Wait()
	local tween2 = TweenService:Create(text,info1,{AnchorPoint = anchorpoint1})
	tween2:Play()
	tween2.Completed:Wait()
end

However, I have no idea how to do this so that the speed (time) always remains the same, no matter how large “x” is. In the code I had tried to solve it with the AbsoluteSize, but this doesn’t really work (see video → initially too fast (tween1) then normal (tween2)).

Is there another way to set the speed (time) so that it stays the same no matter how long the text is or is there a better and more efficient way to bridge this?

By playing around with AbsolutePosition and AbsoluteSize I managed to get the tween of the position. It was important to me to only use one tween. However, I don’t yet know how to calculate the time when tweening, because the value X changes due to the size of the text.

In other words, the longer the text is, the faster the tween is, but this shouldn’t be the case, the speed should remain constant, no matter how large x is.

And here is the full code:

local text = script.Parent.TextLabel

local TweenService = game:GetService("TweenService")

local info = TweenInfo.new(16,Enum.EasingStyle.Linear)

while true do
	text.Position = UDim2.new(0,1300,0,0)
	task.wait(1)
	local tween = TweenService:Create(text,info,{Position = UDim2.new(0,-text.AbsoluteSize.X,0,0)})
	tween:Play()
	tween.Completed:Wait()
end