Best way to save what a player is wearing to data store

I added character customization to my game, and when a player leaves I want the game to save what they looked like. So what I tried doing first was making a table and serializing what they look like. So the first value of the table would be the name of their skin color, then the next would be their shirt ID, and same with pants and face. I started out with the skin color and instead of putting it in the table I wanted to see if it would work with just a regular variable first. I got an error when trying to save the value to data store.
“104: Cannot store int in data store. Data stores can only accept valid UTF-8 characters.”
Here is the code

local SkinColor = char.Head.BrickColor
		SkinColorData:SetAsync(player.UserId.."-SkinColor", SkinColor)
1 Like

Try using tostring to convert the BrickColor to a string

1 Like

You should just index its ‘Name’ property since that’s much more performant than ‘tostring()’.

print(tostring( --Really black
print( --Really black
The relevant property can be found at the bottom of the article.

1 Like