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
--making a table out of the instances
local ExampleTable = workspace.ExampleFolder:GetChildren()
--looping through the table
for _,v in pairs(ExampleTable) do
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 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)
@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?