Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want my player info object to save and load when the player leaves the game.

  1. What is the issue? Include screenshots / videos if possible!

I am trying to save a player info object in a datastore but as in the title, I am getting a error saying I cannot save dictionaries in data stores.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I looked on the devfourm for a while for solutions and tried them, but they didn’t work.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- Constructor
function PlayerInfo.new(player)
	local self = setmetatable({}, PlayerInfo)

	self.Player = player
	self.Key = player.UserId
	self.MaxHealth = 100
	self.Health = self.MaxHealth
	self.Hunger = 100
	self.Inventory = require(Modules.Inventory).new(player)
	self:Load()
	
	AllPlayerInfo[player] = self
	
	return self
end

-- The method that isn't working
function PlayerInfo:Save()
	local Data = {
		SavedInfo = {self}
	}
	
	local success, failure = pcall(function()
		MainDataStore:SetAsync(self.Key, Data)
	end)
	
	if success then
		print(self.Player.Name.."'s data was successfully saved")
	else
		print(self.Player.Name.."'s data failed to save")
		warn(failure)
	end
end

If you’re trying to save data that is not UTF-8 format, you can try to format the data using Base64. This will change it into characters, which the datastore does support.

That’s because you’re trying to save instances :person_facepalming: