So I am currently deciding on whether to continue to serialization for my datastore. I am using Datastore2, and the serialization method. The only problem I face is using serialization would it possible to store duplicates of something, or would it be much better to use a empty table. Unless in the table which using serialization I added something called ["Quantity"] = 1,
and increase it if they get a duplicate. So I have a weapon which has it’s own personal stats in which the player can upgrade it, using the serialization method I would have to make each serial for each upgrade which sounds inefficient, and for table I’m not sure how to add things to it and set them, I guess it would be to get the empty table, and do
table.Insert(Table_name, {
["Name"] = "Wooden Sword",
["Owned"] = true
-- So on for all the stats
})
datastore2:Set(Table_name)
The only problem I face with I don’t know how to retrieve this data and put it into a sword. My current method is:
for num, item in pairs(ReplicatedStorage.Weapons:GetChildren()) do -- Checks all the weapons in the weapons folder
for serial, name in pairs(Weapons.WeaponsTable) do -- Checks table
if item.Name == name["Name"] and name["Owned"] == true then -- if they own it
adding.AddedEvent(item, "Weapons", player)
end
end
end
As you can see if someone was to join the game there data would be incorrect as it doesn’t in count for an upgrade weapon. There is also something else which may be hard to implement and that is an equipped save, so when the leave there equipped weapon should save as the equipped form. I have an idea for how to do this but may be incorrect:
table.Insert(Equip_Table, Weapon, {
["Name"] = "Wooden Sword",
["Equipped"] = true,
-- So on for all the stats
})
datastore2:Set(Equip_Table)
So what I changed in this table.Insert was I added a weapon into the insert which would go to a predefined table with ["Weapon"] = {}
.
Having this could solve an issue of mine, so I have an equip feature in my inventory so when it is equipped it will update the value, and so nothing else could be equipped while something is equipped, I will do this by checking the table which holds the equipped items and would see if there is already something equipped, and if not then equip the weapon. So hopefully you understand where I am going with this, so what I really want to know what would be the best way to approach this? How would I save stats on a weapon? would that be how I set a table? Thank you for reading this. Any Help would be appreciated. Thank you!