(Bad English Warning)
I am creating module which must help to manage players saves.
When it comes to saving tables using JSON it returns weird error which consists of some random numbers and leters (Example below)
Here is my code
local SS = game:GetService("ServerStorage")
local DSS = game:GetService("DataStoreService")
local HS = game:GetService("HttpService")
local Players = game:GetService("Players")
module.LoadInformationFromSaveToDataStore = function(saveName, playerName)
local PlayerFolder = SS:FindFirstChild(playerName)
if not PlayerFolder then error("Player do not have saves") end
local save = PlayerFolder:FindFirstChild(saveName)
if not save then error("Save does not exist") end
local informationToSave = {}
for i, v in pairs(save:GetChildren()) do
informationToSave[v.Name] = v.Value
end
print(informationToSave)
local Key = saveName..tostring(Players[playerName].UserId)
local JSONTOSEND = HS:JSONEncode(informationToSave)
print(JSONTOSEND)
local success, errorMessage = pcall(function()
return DSS:GetDataStore(saveName):SetAsync(Key,JSONTOSEND)
end)
if errorMessage then
error(errorMessage)
end
end