Save table to DataStore

How would I save a table of User Id’s to a data store? e.g. local table = {UserId, UserId}

1 Like

Depends on how you wanna get the UserId’s :thinking: But you can use the SetAsync/GetAsync functions to call for DataStore Saving/Loading

1 Like

Uhh, it’s pretty easy, what I do is when the player data is loaded when they join I add there data profile to a table. I will have custom functions to edit that data in that table. When they are leaving I get that data from the table and I save it. Then I remove it.

2 Likes

I did that but its not working, Im getting the User Id’s by doing:

game.Player.PlayerAdded:Connect(function(player)
table.insert(table, player.UserId)
end)

and then i want to save those Id’s so i can do something with the players next time they join.

1 Like

Here’s a video he basically does the same exact thing I do.

1 Like

Maybe I didn’t explain myself well enough, sorry my bad, let me explain, I don’t want to individually save data within the table (like leader stats), I want to save the entire table, because the table will be empty, it will look something like this “local table = { }” and then I’ll use table.insert to add player Id’s.

Wait, what exactly are you wanting to do with the table? Are you wanting to save it for the server only or globally across every server?

Across every server, so if there User Id is in the table then when they join back into the game, they will be kicked, (kinda like a ban system).

uhh same concept then. just dont save the specific player userid. save with an custom id. then when the player joins just add there userid into the table if it aint there already

1 Like

Sorry I still don’t really understand what your saying, perhaps you could show me how its structured (I’m not asking for a complete script).

Yeah… uhhh that link you sent me, I’m not so keen on it, because it uses a Data Base from a third party, I want to save my tables just within my in game scripts (Data Stores).

make a temp table, get the ban table from the data store make that data the same as your temp so like temp_table = data, then when the player joins add there userid to the temp table, then when ever you want so like every minute or so you can save the temp table into your data store making it the new data. Sorry I took so long to type this i hope you understand now

1 Like

no it uses no third party module, your the one making the module and handling the actual data saving. It may seem like that since he is creating the data handler as a module script and in another script he is calling functions from that module on whether to save or add data

1 Like

How would I get a ban table from a data store? and how would I save this ban table within this data store?

Does the table already have information in it?
If you want to save a table to a datastore, you can do it by something like this:

local Table = {}
YourDataStoreName:SetAsync(Key, Table)

uhh you would saving it using the same key over and over, so when your saving you could use a key like “ban_data_key”.

1 Like

He’s using a website for the data store, I don’t want that, I want to save my table to a Roblox data store with DataStoreService.

no he is not. I do not see how he could be using a website to save his data. He is using roblox data store service

1 Like

If you want to save a table, you can make and use your own unique key.
Data Stores (roblox.com)
How to do a ban system with DataStore - Help and Feedback / Scripting Support - DevForum | Roblox