I have done some research about this and suprisingly, none helped so far.
So what I’m tryna do is, I’m trying to save multiple tables with an inside value.
I don’t actually know if you have to combine each key inside the table or if you can just save a single table containing all of them.
here is my code so far:
local data2 = require(game.ServerStorage:WaitForChild("Datastore2"))
local waitTime = 60
local dataKey = "KeyTestDebug"
local userDataStoreName = "UserDataStore"
--defaultTables
local function setDataTables()
local userData = {
stats = {
["NBux"] = 0,
["Wins"] = 0,
};
inventory = {
["Turret"] = {
Level = 1,
Amount = 1,
};
}
}
return userData
end
game.Players.PlayerAdded:Connect(function(player)
--gettingData
local userData = data2(dataKey, player):Get(setDataTables())
for dataName, dataValue in pairs(userData) do
print(dataValue, dataKey)
end
--savingData
while wait(waitTime) do
data2(userDataStoreName, player):Set(userData)
end
end)
My updating method:
everything worked so far except the saving part. playerremoving or saving every second doesn’t help because I get this message when I leave:
Which makes me really confused. Reminder that I have done countless of research and none helped.