I made a quick save and load function for my player class and in the save function everything seems to work serializedData
looks like this {"stats":{"health":100,"damage":5,"shield":0,"xp":0,"level":1}}
(which is valid JSON according to jsonlint) however when I load the data serializedData
is giving me Instance.
function self.save()
print("Saving")
local data = {
stats = stats.serialize()
}
local serializedData = game:GetService("HttpService"):JSONEncode(data)
print(serializedData)
playerDataStore:SetAsync(userId, serializedData)
end
function self.load()
print("Loading")
local success, serializedData = playerDataStore:GetAsync(userId)
if success then
print("loaded data")
print(serializedData)
local data = game:GetService("HttpService"):JSONDecode(serializedData)
stats = Stats.new()
stats.load(data.stats)
else
print("failed to load data")
end
end