I want to store and load all the pieces in a model, but I do not know how to do that. I thought about doing something like this:
local DSS = game:GetService("DataStoreService")
local datastore = DSS:GetDataStore("GeneralSaveData", "Players")
function generateDataKey(player)
local ret = ("uid_" .. player.userId)
return ret
end
function generateDataTable(player)
local dataTable = {
game.Workspace.TestModel:GetChildren()
}
return dataTable
end
function saveDataForPlayer(player)
local key = generateDataKey(player)
local data = generateDataTable(player)
datastore:SetAsync(key, data)
end
function inputDataToPlayer(player, data)
if data ~= nil then
for datatoload, data in pairs(data) do
data.Parent = game.Workspace.TestModel
end
end
end
end
function loadDataForPlayer(player)
local key = generateDataKey(player)
local data = datastore:GetAsync(key)
inputDataToPlayer(player, data)
end
game.Players.PlayerAdded:connect(function(player)
loadDataForPlayer(player)
wait ()
while true do
wait (60)
saveDataForPlayer(player)
end
end)
game.Players.PlayerRemoving:connect(saveDataForPlayer)
But this script obviously doesn't work. How do you solve this problem?
If there are any I would be happy about tutorial links or similar I did not find any

1 comment
How would you save a table can i use my script from above?