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

Saving a table of names via DataStore? [closed]

Asked by 8 years ago

How do you go about saving the names of items in your Backpack to a table?

Closed as Not Constructive by Perci1 and General_Scripter

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by 8 years ago

Well, you had no go at it at all yourself so I won't explain it at all. It will require changing to fit your needs...

ds = game:GetService("DataStoreService"):GetDataStore("Tools")
ds:SetAsync(game.Players.Player1.userId,game.Players.Player1.Backpack:GetChildren())

To retrieve the data store:

ds = game:GetService("DataStoreService"):GetDataStore("Tools")
tools = ds:GetAsync(game.Players.Player1.userId)
Ad
Log in to vote
0
Answered by 8 years ago

Iterate

local names = {};
for k,v in next, Player.Backpack:GetChildren() do
    names[k] = v.Name;
end;
DS:SetAsync(Key, names)

Assumes DS and Player are predefined as the DataStore and Player respectively.
Also assumes that Key is predefined.