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

Storing more than two values in a datastore?

Asked by
stepatron 103
5 years ago

Is it possible to do something like?

datastore:SetAsync(player.userId, false, 420)

If not, how would I be able to?

2 answers

Log in to vote
6
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

You can store a table in the DataStore.

If you haven't used tables yet, learn more about them here

You would do it like this:

datastore:SetAsync(plr.UserId, {false, 420})
1
I agree. This should work. You should also do this when you are trying to get it: "datastore:GetAsync(plr.userId)[1] -- Thats the 1st variable in it, which returns false" Rawblocky 217 — 5y
0
Yes. [1] would get false, [2] would get 420, etc. Amiaa16 3227 — 5y
Ad
Log in to vote
1
Answered by 5 years ago

I would use a table, I've done it before, but recently forgot how. I think it would be

game.Players.PlayerRemoving:connect(function(p)
local dss = game:GetService("DataStoreService"):GetDataStore("ExampleName")
local data = {1 = 1, 2 = 2}
dss:SetAsync(p.UserId,data)
end)

Answer this question