I’ve been trying for about a week to make a save slots system and I pretty much completed it, but I’ve been stuck at trying to save the folder and its descendants inside a table when the player leaves.
I read articles about serialization but I am having trouble figuring out how to implement it in my game.
This is the layout of the folders and values
Each block contains blockId, Cframe, and Settings. If the block is wired to another object it contains inputObj which is the blockId of the input object. If the block is a control seat, it contains a folder called Keybinds which contains folders of all the blocks that are linked to the seat. Inside the block folders are string values.
Save/Load Script
local HttpService = game:GetService("HttpService")
local data = {}
local DataStore2 = require(game.ServerScriptService.Modules.DataStore2)
DataStore2.Combine("DATA", "SaveSlots")
function data.load(player, abletosave)
local folder = player:WaitForChild("Save Slots")
local SlotsTable = {}
local SlotsStore = DataStore2("SaveSlots", player)
SlotsTable = SlotsStore:Get()
print(SlotsTable)
if SlotsTable then
--This is where it is supposed to convert the table back into folders and values
end
abletosave.Value = true
end
function data.save(player, abletosave)
local SaveSlots = player:WaitForChild("Save Slots")
if abletosave.Value == true then
local SlotsStore = DataStore2("SaveSlots", player)
local slots = {}
--I can't figure out how to convert the folder's descendants into a table here
SlotsStore:Set(SaveSlots)
end
end
return data