Weird error when trying to save JSON with datastore

(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

I am feeling dumb.

Well the problem was that i used error() instead of warn() it looks like strange numbers was just reply from server which i recognized as error

Now my code works great

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.