I have a "HiddenLeaderstats" in the player that holds all of the players data. How do i save the folder
Datastores dont accept instances, so you will have to pack all of the data into a table. To do this, do the following in a server script:
DataStore = game:GetService("DataStoreService"):GetDataStore("Data") game.Players.PlayerRemoving:Connect(function(plr) local saveTable = {} for _,v in pairs(plr.HiddenLeaderstats:GetChildren()) do table.Insert(saveTable,v.Name,v.Value) end pcall(function() DataStore:SetAsync(plr.UserId,saveTable) end) end) game.Players.PlayerAdded:Connect(function(plr) wait(1) local data = pcall(function() return DS:GetAsync(plr.UserId) end) for i,v in pairs(data) do local value = plr.HiddenLeaderstats:FindFirstChild(i) if not value then return end value.Value = v end end)
This will save all data in a hidden folder under the player named "HiddenLeaderstats". It will pack and unpack all data under the folder, but will NOT make the data values when the player joins. I hope this helped.