I am trying to create a daily chest system where multiple chest’s last opened time will be stored in a table with DataStore2
This is my first time using DataStore2, and here is the code inside the server script service.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local DataStore2 = require(ServerScriptService.DataStore2)
local ChestTable = {
d1 = DateTime.fromUniversalTime(1999,1,1,1,1,1,1),
d2 = DateTime.fromUniversalTime(1999,10,3,4,4,4,4)
}
--This table is supposed to be the table that a new player will start with
DataStore2.Combine("DATA", "chest")
Players.PlayerAdded:Connect(function(player)
local chestData = DataStore2("chest", player)
local function callRemote(value)
print(value[1])
ReplicatedStorage.Events.DailyChest:FireClient(player, value)
end
-- If this is their first time playing the game, they'll start out with a default table
callRemote(chestData:Get(ChestTable))
-- Everytime a chest opened we'll send the RemoteEvent again.
chestData:OnUpdate(callRemote)
end)
it says value is not a table, how do I save the table correctly