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.
