Before I figured this out I was creating individual values for a lot of things. But I wanted a solution to storing the data of my randomly generated NPCs very efficiently. All the data for these npc is stored in over 35 different value instances. It was based off my character customization system that uses all the native R15 character features for customization such as scaling ,clothing and interchangeable body parts.
I don’t know if you have ever thought about doing something similar for data storage but being able to store table data in a string is pretty useful. I just discovered it moments ago
-- Define a function to convert a folder of values into a table
local function FolderToTable(folder)
local table = {}
for _, value in pairs(folder:GetChildren()) do
table[value.Name] = value.Value
end
return table
end
-- Define a function to convert a table into a string
local function TableToString(table)
local string = ""
for key, value in pairs(table) do
string = string .. key .. ":" .. tostring(value) .. ";"
end
return string
end
-- Define a function to convert the string back into a table
local function StringToTable(string)
local table = {}
for key, value in string:gmatch("(.-):(.-);") do
table[key] = tonumber(value) or value
end
return table
end