I've looked at a bunch of other scripts using JSON to encode/decode tables to save, I did what they did, changing only the names of things, yet when I try to load in my data, it says 'Cannot parse JSON'. Is there an issue with my saving? Any help would be greatly appreciated.
Edit: Entire code added
geldSave = game:GetService('DataStoreService'):GetDataStore('geldSave')
chibiLoad = game:GetService('DataStoreService'):GetDataStore('chibiLoad')
game.Players.PlayerAdded:Connect(function(plr)
wait(1)
local geld = Instance.new('IntValue')
geld.Name = 'ChibiCoins'
geld.Parent = plr
local own = Instance.new('Folder')
own.Name = 'OwnedChibi'
own.Parent = plr
local success, err = pcall(function()
if geldSave then
local money = geldSave:GetAsync(plr.UserId)
if money then
geld.Value = money or 100
end
end
if chibiLoad then
local chibi = game:GetService('HttpService'):JSONDecode(chibiLoad:GetAsync(plr.UserId))
for _,v in pairs (chibi:GetChildren()) do
print(v.Name)
end
end
end)
if success then
warn(plr.Name .. ' Data Loaded')
elseif err then
warn(err)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local chibis = plr.OwnedChibi:GetChildren()
local success, err = pcall(function()
chibiLoad:SetAsync(plr.UserId, game:GetService('HttpService'):JSONEncode(chibis))
geldSave:SetAsync(plr.UserId, plr.ChibiCoins.Value)
end)
if success then
warn(plr.Name .. ' Saved')
elseif err then
warn(err)
end
end)
game:BindToClose(function()
local function onRemove(plr)
local chibis = plr.OwnedChibi:GetChildren()
local success, err = pcall(function()
chibiLoad:SetAsync(plr.UserId, game:GetService('HttpService'):JSONEncode(chibis))
geldSave:SetAsync(plr.UserId, plr.ChibiCoins.Value)
end)
if success then
warn(plr.Name .. ' Saved')
elseif err then
warn(err)
end
end
for i,v in pairs(game.Players:GetPlayers()) do
onRemove(v)
end
end)
end)

4 comments
Are you sure it's in JSON format? EXAMPLE: {["SomeValue"] = "1"}
The instances in the folder are BoolValues set to true, so I believe so. Unless I'm misunderstanding this: https://www.json.org/json-en.html
What's the code bit when you load the data, or maybe what's your whole code?
I've edited the whole code into it now.