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

With DataSave, possible to save 2 values to 1 save?

Asked by
dirk2999 103
6 years ago

Basically I'm trying to make a game where people buy 'carts' and can upgrade them from 1-5. I would like to save the carts they own, and the upgrades they added on that cart.

I understand with data save you can have multiple values saved, like

[1] = 1 [2]= 4

So when using :GetAsync you can get the first or second value.

I was wondering if you could get the values to strings for example

["Red Cart"] = 1 ["Blue Cart"] = 4

Something like that. And when I used :GetAsync I could search for the string I needed and the number that pertained to the string. If there's no way to do that how do I go around that?

1 answer

Log in to vote
0
Answered by
mraznboy1 194
6 years ago

Yup, you can. By saving a table, you're able to save a lot of data at once. For instance:

local data = {
    Carts = {
        Blue = 4,
        Red = 1
    }
}

pcall(function()
    :SetAsync(player_id, data)
end)
Ad

Answer this question