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

Can you store a 2D array in data store? [ANSWERED BY THE AMAZING KINGDOM5!] [closed]

Asked by 7 years ago
Edited 7 years ago

Hey guys,

I'm working on a game recently that needs to store both the Inventory Items and the Stats of the Player and that provides me with 2 arrays so, I decided to make an array of arrays just in-case I will need to store more items in the future. Below is a personal example of what I mean by this.

local players = game:GetService("Players");
local ds = game:GetService("DataStoreService"):GetGlobalDataStore("Player's Storage");

function Player_Entered(plr)
    local key = "player-"..plr.UserId;

    local data_to_get = ds:GetAsync(key);

    if data_to_get then
        -- Just setting the values equal to this 2D array that it receives. (If Data Store Supports 2D Arrays)
    end
end

function Player_Leaving(plr)
    local Values_To_Save = {{VALUES}, {VALUES}} -- Just think that there are values stored inside of them. Not user data values but, values like ints/strings/booleans.
    local key = "player-"..plr.UserId;

    ds:SetAsync(key, Values_To_Save);
end

players.PlayerAdded:Connect(Player_Entered);
players.PlayerRemoving:Connect(Player_Leaving);

Well, any help is appreciated and if you have any questions about this question then please, comment below.

Locked by shayner32

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?