How to check which gui objects inside ScrollingFrame are visible and which are invisible without lag?

ScrollingFrame in my plugin can contain up to 100k+ frames inside it. Each frame has 2 ImageLabels and 2 TextLabels. This creates a lot of lag when scrolling. So I though of creating something similar to Roblox’s content streaming, but with gui. I need to know, which frames inside ScrollingFrame are currently visible and which are not in a very performant way. Keep in mind that looping through all frames won’t work as there can be up to 100k+ frames and this would create even more lag.

Here is an example code using in a local script to check it but… what’s the point of having +100k frames in your gui ???

local ScrollingFrame = script.Parent --Change by where your scrolling frame is.

for _, Frames in pairs(ScrollingFrame:GetChildren())do
	if Frames:IsA("Frame") and Frames.Visible == true then
		--code ?
	elseif Frames:IsA("Frame") and Frames.Visible == false then
		--code ?
	end
end

That is not what I meant. My plugin is for searching for certain string inside all scripts.


And for the “ab” search it shows 9829 frames. As you can see, only 14 of them are visible and other ones are not as they are cut off by the ClipsDescendants property.

There are many posts on the dev forum which can help you, like this one:

I’ll try this later, thanks.

1 Like