What order do newly created instances take?

Hey everyone, I just have a simple question about how roblox runs behind the scenes, so if someone could clarify this to me that would be amazing.

So I create a sequence of instances and place them in an empty folder. Then I make a table out of those instances.
And what I need to know is whether the table will use the same order as when I made the instances. So for this example it would have to print Part1, Part2, Part3, Part4, Part5 in that order.

--creating a sequence of instances
for i = 1,5 do
 local newpart = Instance.new("Part")
 newpart.Name = "Part"..i
 newpart.Parent = workspace.ExampleFolder
end

--making a table out of the instances
local ExampleTable = workspace.ExampleFolder:GetChildren()

--looping through the table
for _,v in pairs(ExampleTable) do
 print(v.Name)
end

I have tested it out a few times and it seems to use the same order every time, but I’m not 100% sure. And I will need this to save that table in a DataStore (I only save the names not the instances), and the instances will not be numbered. So will it still work every time in that case?

Usually looping through a table with a pairs loop would be basically taken in a randomized setup

You probably want ipairs, which would iterate through the table in a chronological order (Or starting from the first value in the table, and ending at the last value aka Left to Right)

Also side note, but you can’t save Instances in Datastores if that’s what your plan was

1 Like

Oh okay, but the chronological order, is that the order the instances are created in?

And yes sorry I know that, I only save the names of the instances but I forgot to say that in the post. (I editted it now)

But thanks for your quick reply.

Usually it is in chronological order HOWEVER you should never trust that it is always in chronological order. (Note that I am assuming that :GetChildren does things similarly to what the post says so feel free to correct)

Best you sort the table yourself to avoid creating weird bugs in the future.

This post discusses that (A little overblown on his part but still useful)

1 Like

in for i,v in pairs the order is up to down when a new instace is created it appears at the bottom area of the parent

1 Like

@Jackscarlett @UnknownParabellum @Qinrir Alright thanks everyone for your replies, I think I get it now. You all helped me but I just marked Jackscarlett’s reply as the solution so that this post appears as solved.

So if I understand everything correctly this should work:
The new instances will appear at the bottom of the parent each time, which already assures a correct order in the game explorer. If I then save the names of the instances inside a table by looping through those children using an ipairs() loop, the order will remain the same as in the game explorer since it’s an array and not a dictionary. Is that correct?

no problem always here to help