Argument Missing or Nil on :SetAsync()

This datascript is meant to save what characters you have, but when you disconnect (on line 22), it shows this error message -
Argument 2 missing or nil

NOTE, ONLY THE CHARACTERS PART IS IMPORTANT.

Anyone could help me, thanks.

local datastore = game:GetService("DataStoreService")
local datareal = datastore:GetDataStore('DataStore')

game.Players.PlayerAdded:Connect(function(plr)
	
	local instance = Instance.new('BoolValue',plr)
	instance.Name = "Muted"
	instance.Value = false
	
	local folder = Instance.new('Folder',plr)
	folder.Name = "Characters"
	
	for i,v in pairs(game.Lighting.Characters:GetChildren()) do
		local character = Instance.new("BoolValue",folder)
		character.Name = v.Name
		
	end
	datareal:GetAsync(plr.UserId, plr.Characters:GetChildren().Value)
	

	game.Players.PlayerRemoving:Connect(function(plr)
		datareal:SetAsync(plr.UserId, plr.Characters:GetChildren().Value )
		end)

	
	
end)

Because you are assigning value to a table. :GetChildren() returns a table.

You would need to use a for loop, go through everything that’s inside the folder then add the values to a table to save with the appropriate key. And you also did not parent the folder where you’re getting the values.

local Table = {}

for index, character in ipairs(folder:GetChildren()) do
     table.insert(Table,character.Value)
end