Making Frames Visible in a chronological order

so i am making a transition for my game which has 77 frames. i want the frames to be visible in a chronological order but it doesn’t! i don’t know what to do so i would appreciate the help!

Script (part where i have the problem):

local gui = plr.PlayerGui
local transition = gui.Transition
	
for i, v in pairs(transition:GetChildren()) do
	v.Visible = true
	wait()
end
1 Like

Pairs() doesn’t go in order, try iPairs.

1 Like

it still goes the same as it was

2 Likes

You should name all the frames in a numeric order then have the for loop go through each index then turn that into a string and index it that way

1 Like

i had the frames named in a numeric order from the start

Then instead of using GetChildren, use a generic for loop starting from 1 to the numbers of frames you have. For example:

for i = 1,77 do
   local obj = transition[i..""]
   obj.Visible = true
   task.wait()
end

ok! thank you for this! now it works with this code:

for i = 1,77 do
	transition:FindFirstChild(i).Visible = true
	wait()
end

Here’s a more dynamic solution that’ll work with any number of children.

local children = transition:GetChildren()
table.sort(children, function(Left, Right)
	return tonumber(Left.Name) < tonumber(Right.Name)
end)

for _, child in ipairs(children) do
	child.Visible = true
	task.wait()
end
1 Like

In that case, you could just use a generic loop and have it end at the number of children without having to sort through each child as that is essentially what your solution does.

Might look something like this:

local children = transition:GetChildren()
for i = 1, #children do
   transition[i].Visible = true --Concatenate if the frames have a prefix/suffix in their name
   task.wait()
end

Purposefully avoided doing this in case there were gaps, i.e; transition[10] didn’t exist. You could use transition:FindFirstChild[i] to remedy that though.