You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to save the data of an item the player has. My game will hat items and some weapons can be enchanted/may have stuff like durability you know? I want to save the data to a datastore for each player
What solutions have you tried so far?
I currently have an inventory data system in a table. I already tried saving a table within a table, but that doesnt work obviously. I thought about multiple datastores but thats extremely messy. What i am looking for is the most effective way to put an item into a table or other form of storable data and call it back later, along with its data such as Enchantments or such that’ll make it different than other items of the same model (i.e. a enchanted sword is different than a normal sword, or a sword with a different enchantment)
local datastoreModule = require(game.ServerScriptService.Data.MainModule);
local dataname = require(game.ReplicatedStorage.STORAGE.storageInfo.infoDatastores)[script.Name]
game.Players.PlayerAdded:Connect(function(plr)
local currentDatastore = datastoreModule(dataname, plr)
local datatable = {
}
if currentDatastore:Get() ~= nil then
for i = 1,#datatable do
if currentDatastore:Get()[i] == nil then
table.move(datatable, i, i, i, currentDatastore:Get())
end
end
datatable = currentDatastore:Get()
else
currentDatastore:Set(datatable)
end
game.Players.PlayerRemoving:Connect(function(newplr)
if plr.Name == newplr.Name then
if not plr.Backpack:FindFirstChild("Backpack") then return end
local newinvtable = {}
for i,Item in pairs(plr.Backpack:FindFirstChild("Backpack"):GetChildren()) do
table.insert(newinvtable, Item.Name)
end
currentDatastore:Set(newinvtable)
end
end)
end)