Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Do datastores save and load in order?

Asked by 5 years ago
Edited 5 years ago

The title says it all, if I save a table, do all the items within the table load in the correct order? If I can't do that, what can I do that will help me load in correct order?

--No script provided-- example,

local tbl = {1,2,4}

when saved the tbl, will it load in exact same order, 1,2,4 or will it just take like... 2,4,1

1
I've worked with data stores in the past, saving tables specifically, and it does save in order User#19524 175 — 5y
0
Thanks Incapaz greatneil80 2647 — 5y

1 answer

Log in to vote
2
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago

There are two types of tables; arrays and dictionaries. Arrays are the "normal" tables, where the keys are automatically assigned to integers (e.g. 1, 2, 3, 4), and because of this they always keep their order. So, your example table (which is an array) will keep the order when being loaded or saved through datastore.

However, if your keys are not integers, like in dictionaries, there will be no order in the table. This is fine though since dictionaries allow you to better categorise your tables. My answer here outlines how you could use dictionaries with datastores for a save system.

0
Thx dude greatneil80 2647 — 5y
Ad

Answer this question