MainScroll contains all the characters with a UIListLayout (Horizontal). This is the frame that actually moves to reveal the next characters.
“i” is the current character position in the full test. Since each character label is named with it’s position, MainScroll[i] is getting the label in that position.
If you want it, here’s a larger chunk of the script:
local FullString = ""
local WordCount = 25
for i = 1, WordCount do
if i == WordCount then
FullString = FullString..WordList[math.random(1, #WordList)]
else
FullString = FullString..WordList[math.random(1, #WordList)].." "
end
end
for i = 1, #FullString do
local NewChar = script.character:Clone()
NewChar.Parent = MainScroll
NewChar.LayoutOrder = i
NewChar.Text = string.sub(FullString, i, i)
NewChar.Name = i
end
print(#FullString)
for i = 1, #FullString do
local Character = string.sub(FullString, i, i)
local HasDoneInput = false
local Connection = UserInputService.InputBegan:Connect(function(input)
if Character == " " then
if input.KeyCode == Enum.KeyCode.Space then
HasDoneInput = true
else
MainGame.Parent.GameSounds.Error:Play()
MainScroll[i].TextColor3 = Color3.new(1, 0, 0)
end
else
if input.KeyCode == Enum.KeyCode[string.upper(Character)] then
HasDoneInput = true
else
MainGame.Parent.GameSounds.Error:Play()
MainScroll[i].TextColor3 = Color3.new(1, 0, 0)
end
end
end)
repeat task.wait() until HasDoneInput
MainGame.Parent.GameSounds.Type:Play()
print(i, Character, "successful.")
Connection:Disconnect()
MainScroll[i].TextTransparency = 0
MainScroll[i].TextColor3 = Color3.new(1, 1, 1)
MainScroll.Position -= UDim2.fromOffset(MainScroll[i].AbsoluteSize.X, 0)
end
Instead of continuously remove some amount of pixels, I made it calculate the (negative of the) distance between the left side of MainScroll, to the left side of the character, and use that number to calculate by how much MainScroll should move to the left
This approach avoids the accumulation of errors (for example, if you add up a lot of results with small imprecision, they add up to a big imprecision, but here, nothing is getting added up, as per the absence of -=)
The video you showed doesn’t lead me to believe accumulation of imprecision was the cause, as it should take way more than a couple characters to accumulate imprecision, and in theory their position is in pixels, and roblox doesn’t support (yet) decimal pixels, so there shouldn’t be floating point imprecision here
If you UIListLayout has padding or something, that could also be the cause of your issue. Either way, the approach I gave should be more reliable regardless