Hello, i am asking that is it possinble to save Dictionary’s in DataStoreService, i am using Profile Service and i cant, i tried doing it with HTTP:JSONEncode() then Decode but it doesnt work, is it possible ?
If yes, how?
Hello, i am asking that is it possinble to save Dictionary’s in DataStoreService, i am using Profile Service and i cant, i tried doing it with HTTP:JSONEncode() then Decode but it doesnt work, is it possible ?
If yes, how?
It is possible to save dictionaries within a regular DataStore.
OrderedDataStores however can only save numbers.
There’s no reason to be encoding the dictionary into JSON either.
--Example code
local DataStoreService = game:GetService("DataStoreService")
local mainDataStore = DataStoreService:GetDataStore("Main DataStore")
game:GetService("Players").PlayerRemoving:Connect(function(player)
local dataToSave = {}
dataToSave['Credits'] = player.leaderstats.Credits.Value --Example value to save inside a dictionary
local success, err = pcall(function()
mainDataStore:SetAsync(player.UserId, dataToSave)
end)
--Make sure to include fail saves!
end)
thanks for your help, ill try it