Why isn't table being stored in datastore2?

I’m making a saving system using datastore2 that saves the properties of every part in a grid. It’s being added in a table, but when I try to save it to the datastore and print it, it doesn’t seem to be printing anything.

ver = 2
--just using a wait for now, too lazy to make a click detector

local players = game:GetService("Players")
local dataStore2 = require(1936396537)
local userDataStoreName = ver.."SavingSys"

local player
    player = plr

local save = {}
for i,part in pairs(game.Workspace.Playspace:GetChildren()) do
    if part then
        save[part.Name] = {["pos"] = part.Position, ["color"] = part.Color, ["mat"] = part.Material}

dataStore2(userDataStoreName, player):Set(save)
print(dataStore2(userDataStoreName, player))
1 Like

Are you testing this in studio?

Studio servers usually close too quickly for DataStores to even work most of the time. Try testing this in a normal roblox server and see what prints out in your output.

Hope this helps!! :grin:

If you are doing this in studio then you need to create a BoolValue in ServerStorage named SaveInStudio and make sure it is set to true. Otherwise Datastore2 won’t save at all in studio, you shouldn’t have to worry about :BindToClose() because that is already a built-in feature.

I understand you are also going to add a ClickDetector, but the bad practice of waiting 10 seconds might be an issue in your script as well.