print(DataStoreId)
print(plr)
local DataBase = game:GetService("DataStoreService")
local ClonedPlayerData = script.PlayerData:Clone()
ClonedPlayerData.Parent = plr
ClonedPlayerData.Name = "PlayerData"
local function Scan(child)
for index,child in pairs(child:GetChildren())do
if (child:IsA("Folder")) then
Scan(child)
else
local success = pcall(function()
local DataStore = DataBase:GetDataStore(child.Name..DataStoreId)
child.Value = DataStore:GetAsync(plr.UserId)
end)
if success then
print("got synced in data for "..child.Name)
else
print("set synced in data for "..child.Name)
DataBase:SetAsync(plr.UserId, 0)
end
end
end
end
end;
SaveData = function(Table,plr,DataStoreId,...)
local DataBase = game:GetService("DataStoreService")
local function Scan(child)
for index,child in pairs(child:GetChildren())do
if (child:IsA("Folder")) then
Scan(child)
else
local success = pcall(function()
local DataStore =
DataBase:GetDataStore(child.Name..DataStoreId)
if (child:FindFirstChild("Changed")) then
if (child.Changed.Value == true)then
DataStore:SetAsync(plr.UserId,child.Value)
end
end
end)
if success then
print(plr.Name.."set synced in data for "..child.Name)
else
print(plr.Name"Unable to set async for"..child.Name)
end
end
end
end
end
This is a Data Store in my core module that loops through a bunch of folders inside player data and saves all the values inside of them. I considered making a table instead of a object oriented player data but I feel like it is more easy for me to just use the folders doing that. I am planning on making a building style game that needs to save all your builds and I don’t feel like this data store is able to do that. If you can, please feel free to show me a better way to create this data store.