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

What is the format for saving tables in DataStores?

Asked by 8 years ago

Hi everyone, I'm currently working on a perm ban system using DataStores. For this to work efficiently, it needs tables. I don't know what is the correct format to create tables in DataStores. Do I just make up the table name and it will appear?

Here is some example code

store:GetAsync(key, table.insert([TABLE NAME HERE], id)

1 answer

Log in to vote
0
Answered by
lukeb50 631 Moderation Voter
8 years ago
store:SetAsync("TableName",{})

this would create a blank table in a datastore

0
How would I add values to the table then? KianTrains 5 — 8y
0
put the values in {} lukeb50 631 — 8y
0
Yes, but it gets added in-game, meaning it would have to be table.insert() or something. KianTrains 5 — 8y
0
then use getasync(),insert it, and save it back the the datastore lukeb50 631 — 8y
View all comments (2 more)
0
store:SetAsync("BanTable", add) add is the table.insert(), it comes out with argument 2 missing. KianTrains 5 — 8y
0
In this situation, you'd want to use :UpdateAsync() as there is potential for it to be changed by multiple servers. With it, check if an old value is there, and call `table.insert(THE_TABLE, NEW_BANNED_PLAYER)` on it. PowerHotmail123 90 — 8y
Ad

Answer this question