So this is me getting the StringValue and then putting it into a dictionary so I can do deserialization and then serialize it again into a value/increment so the datastore can store it. What I'm trying to do right now is get the datastore with DataStore2:Get() I've tried a few ways and it hasn't worked does anyone have any ideas?
game.Players.PlayerAdded:Connect(function(player)
local data = Instance.new("Folder", player); data.Name = "Database"
local names = Instance.new("StringValue", data); names.Name = "NameValue"
local NAME_VALUE = player.Database.NameValue.Value
local ItemsDictionary = {
["namevalue"] = player.Database.NameValue.Value
}
local nameStore = DataStore2("Name", player)
nameStore:BeforeInitialGet(function(serialized)
local deserialized = {}
for _, id in pairs(serialized) do
local playerName = ItemsDictionary[id]
deserialized[playerName] = true
print(deserialized)
end
return deserialized
end)
nameStore:BeforeSave(function(deserialized)
local serialized = {}
for playerName in pairs(deserialized) do
for NameId, name in pairs(ItemsDictionary) do
if name == playerName then
table.insert(serialized, NameId)
print(serialized)
end
end
end
return serialized
end)
