Datastores not accepting bool values as UTF-8 Characters?

Making a new game I created a datastore. I’m trying to save a boolvalue but whenever i leave i get this error. ‘104: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters.’

local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("PlrData1")

local function savePlayerData(player)
	local Values = {
		player:WaitForChild("data").CuttingBoard_Unlocked
	}
	
	local success, err = pcall(function()
		dataStore:SetAsync(player.UserId, Values)
	end)
	if success then
		print("Woohoo Our data is saved")
	else
		print("the data died")
		warn(err)
	end
end

game.Players.PlayerRemoving:Connect(function(player)
	savePlayerData(player)
end)

game:BindToClose(function() -- When the server shuts down
	for _, player in pairs(game.Players:GetPlayers()) do
		savePlayerData(player) -- Save the data
	end
end)

game.Players.PlayerAdded:Connect(function(player)

	local CuttingBoard = player:WaitForChild("data"):WaitForChild("CuttingBoard_Unlocked")

	local data
	local success, err = pcall(function()

		data = dataStore:GetAsync(player.UserId)

	end)

	if success and data then

		CuttingBoard.Value = data[1]

	else
		print("The player has no data!")
		CuttingBoard.Value = false
	end

end)

You could get the CuttingBoard_Unlocked value and not the object itsself.

1 Like

Oh damn, This is still my 3rd time with datastores, Its always the small details that get me.

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