Saving player's character

Just wondering how you could save a player’s entire character using datastore service. I’ve tried but my second argument is considered to be nil. Any answers would be appreciated.

Code:

game.Players.PlayerRemoving:Connect(function(plr)
	local plrID = 'Player_'..plr.UserId
	
	local data = plr.Character
	
	local success, errormessage = pcall(function()
		charDataStore:SetAsync(plrID, data)
	end)
	
	if success then
		print('saved')
	else
		warn(errormessage)
	end
end)

Unfortunately, there is no way you can save models in Datastore, sorry.

Sadly, I don’t think there is a way to use DatastoreService to directly save a model.

What you could do is save all of the ids, accessories and the body colors into some sort of table and save that. Unfortunately, that is all I can suggest.

You may find this article useful:

Hope you find out a solution :slightly_smiling_face:

You save the values of their HumanoidDescription to a data store, and then apply those after you load them again.

Basically, What everyone means is.

You can’t save INSTANCES to DataStores.

You can save hats, stats, or even the position of some parts. I don’t know what your trying to reach/achieve.

If your trying to save lots of stuff, Create a table when the player leaves, do a for in pairs of the Character Children, and insert them into the table, then SetAsync()

for _,Hat in pairs(Player.Character:GetChildren()) do
      table.insert(YourTable,Hat.Name)
end

And then, when the player enters back, you can use these names to do stuff with strings.

Also yeah, you can also use the HumanoidDescription to save some values you need.

Because I have set character models(uncustomizable), I just made it so that I’d save the name of the character model the player had, then would re-morph them when they joined back. Thanks for everyone who tried to answer my question, though!