Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can ScrollingFrames scroll infinitely?

Once again, another plugin. I won't go into much detail about it but I have a ScrollingFrame which can have infinite children and descendants. Each frame is offset 100 pixels below and to the right of the "Parent" in the "tree".

If you know the answer then please reply.

Thanks, PoWerofThEePg

2 comments

0

Test it out yourself

0

I did, that is why I asked the question here.

1 answer

Short answer

No

Long answer

Sort of, its hard to tell exactly what you want. Do you want a ScrollingFrame that truncates dynamically depending on its descendants? Cause that can be done.

But a ScrollingFrame with infinite CanvasSize is impossible, unless you get creative.

Dynamic ScrollingFrame

If the dynamic ScrollingFrame is what you want its actually quite easy. All you need to do is get the children of the ScrollingFrame and get their size and add them all together.

Ex. This truncates a ScrollingFrame that contains ui sorted by a UiListLayout vertically

local children = ScrollingFrame:GetChildren()

for i = 1, #children do
	if not children[i]:IsA(any instance type you might want to avoid) then
		local offset = offset + children[i].Size.Offset.Y
		local scale = scale + children[i].Size.Offset.Y
	end
end

ScrollingFrame.CanvasSize = UDim2.new(0, 0, scale, offset)

You will have to adapt this code to whatever you are working on

"Infinite" ScrollingFrame

You can create a pseudo-infinite ScrollingFrame by using a tillable background and resetting the position whenever the pattern matches.

Ex. the variables in this script can vary a lot. You will defiantly need to customize it.

local RunService = game:GetService("RunService")

local maxDistX = 100
local minDistX = -100
local maxDistY = 100
local mixDistY = -100

RunService:HeartBeat(function()
	if ScrollingFrame.CanvasPosition.X >=  maxDistX or ScrollingFrame.CanvasPosition.X <=  mixDistX or ScrollingFrame.CanvasPosition.Y >=  maxDistY or ScrollingFrame.CanvasPosition.Y <=  mixDistY then
		ScrollingFrame.CanvasPosition = Vector2.new(0, 0)
	end
end)

Big ScrollingFrame

And in the end you could just set the canvas size to a huge number, but thats not really infinite.

Ex.

ScrollingFrame.CanvasSize = UDim.new(math.huge, math.huge, math.huge, math.huge)

1 comment

0

What mould mixDistX be? Is it a misspelled version of maxDistX?

This discussion is preserved as it was. New answers, comments, and votes are closed.