Function is stuck at UIGridLayout (first child)

I’m attempting to create a pop-up frame that consists of data from an order in a ScrollingFrame, but it doesn’t seem to for _, i in pairs for the lower section. I’ve noticed that the upper section had premade frames and it works as intended, however, the lower section, in which gets cloned frames, fired from a RemoteEvent, doesn’t - and only print(i) out UIGridLayout as the only child - whereas, other frames get cloned, and get ignored? What’s the issue here?

Code:

local top = donateH.SectionTop; local low = donateH.SectionLow; local lowBox = low.Box
local function loop(typ)
	for _, i in pairs(donateH:FindFirstChild(typ.Name).Box:GetChildren()) do
        print(i) --for low, it only prints UIGridLayout - an issue here. But for top, it prints out every child, making it work as intended.
		if i:IsA("UIGridLayout") then --apparently, it's low's only child, whereas frames get cloned in a certain amount of time (top already has premade ones, therefore it doesn't require cloning)
			return --that's it for loop(low), the code is finished
		end
		typ.UserHolder.Username.Text = i.Username.Text; typ.DescHolder.Description.Text = i.Description.Text; typ.Ranking.Text = i.Ranking.Text; typ.Ranking.TextColor3 = i.Ranking.TextColor3
		ts:Create(typ.AvatarImage, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, true, 0), {ImageTransparency = 1}):Play(); 	ts:Create(top.Amount, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, true, 0), {TextTransparency = 1}):Play()
		coroutine.wrap(function()
			wait(.3)
			typ.AvatarImage.Image = i.AvatarImage.Image; typ.Amount.Text = i.Amount.Text
		end)()
		for _, c in pairs(typ:GetChildren()) do
			if c:IsA("Frame") then
				local label = c:FindFirstChildWhichIsA("TextLabel")
				label.Position = UDim2.fromScale(0, 1)
				tween(label, .5, "out", {Position = UDim2.fromScale(0, 0)})
				coroutine.wrap(function()
					wait(4.5)
					tween(label, .5, "out", {Position = UDim2.fromScale(0, -1)})
				end)()
			end
		end
		wait(5)
	end
end
coroutine.wrap(function()
	repeat wait()
		loop(top); wait() --works as intended
	until false
end)()
coroutine.wrap(function()
	repeat wait()
		loop(low); wait() --doesn't work as intended
	until false
end)()

Before:
image
After:
image
It still only prints out “UIGridLayout”, i.Name, rather than frames that have been cloned.

Example of top section working, whereas lower section doesn’t:
https://gyazo.com/bb7cec1f6fd33308149aadf3faf5dad6

Update
It seems to only work for UIGridLayout, not anything else. Whenever I attempt to use for i = 1, #n, it seems to only print out 1 (UIGridLayout), and doesn’t move on, whereas it prints out the exact amount of children. I tried adding a frame, and it only printed out UIGridLayout. What’s the issue here?

1 Like

Do you clone the frames from a local script, and check the children from a server script?

The frames were cloned from a localscript, alongside was used for checking children.

When you return, you basically finish the function.
Therefore, in every loop, the function stops at UIGridLayout, causing it to stop every time at the UIGridLayout.

Instead, just add an if to skip the current iteration if its a Layout

1 Like

That’s honestly irritating, I assumed that it’d skip the child, rather than breaking the loop itself. Thank you for the assistance!

1 Like

No problem :slightly_smiling_face:.
I am pretty sure you’re looking for continue instead of return.
It just goes to the next part in the loop.
You can also just increase i by 1 if it’s a layout, making it basically skip the current object in i.

Edit:
Yes, you can use continue, I just tested:
image
image

1 Like