I’m trying to figure out what causes this obscure error to show up, but without any success so far
function PlayerDataStore.Save(Player: Player)
local PlayerData = ServerStorage:WaitForChild("PlayerData")[Player.UserId] -- ModuleScript
local Data = require(PlayerData)
local Success, Error = pcall(function()
return DataStore:SetAsync(Player.UserId, Data)
end)
if Error then
error(Error)
end
end)
Yes and No, you can save tables by converting it into JSON. you can do this by doing it like this:
local HTTP = game:GetService("HttpService")
local a = {Sample = 123}
local encode = HTTP:JSONEncode(a) -- use JSONDecode to make it table/dictionary again.
print(type(encode)) -- string
are you sure that the :JSONEncode() is necessary? both versions of the code output the same error. also I realized the data saving still works regardless of it
function PlayerDataStore.Save(Player: Player)
local PlayerData = ServerStorage:WaitForChild("PlayerData")[Player.UserId] -- ModuleScript
local Data = require(PlayerData)
local Success, Error = pcall(function()
return DataStore:SetAsync(Player.UserId, Data)
end)
if not Success then -- changed here
warn(Error)
end
end)