Best way of saving HumanoidDescription in DataStores?

I’m trying to save and load a full outfit of a Humanoid (by using ROBLOX’s assets, of course) through the HumanoidDescription property. What’s the best way of achieving this through DataStores? Considering the amount of data that would need to be saved, is it going to affect efficiency if used in a larger server? What’s the best workaround for this?

What’s your use case? There is probably a better way to do what you’re trying to accomplish.

You only need a single datastore call to save it, and no, it won’t create any issues.
The amount of data you’re going to save is nowhere near the limit.

You should save the accessory type and name.
Example:

local Table = { ['BackAccessory'] = id }
2 Likes

Curious about this bit; wanted to ask this for quite a while since I never used that type of formatting (the [‘BackAccessory’] = id); I would just usually save IDs individually.

If I was to load the table into the game with datastores, how would I use this content format ([‘BackAccessory’] = id) in the actual script? And, considering a single HumanoidDescription category can contain multiple IDs, what happens in that case?

I really hope I’m not bothering you! I get where you’re going with this, so I can perhaps work it out myself if there are any threads on the actual Wikia that you could share.

1 Like

For multiple ids you can use an array.

local Array = { ['BackAccessory'] = {id1, id2, id3} }

I haven’t looked into HumanoidDescription, you can probably just apply the id, as I don’t believe it requires you to specify the type.
You’ll find that out though.

Links -
https://developer.roblox.com/en-us/api-reference/function/Humanoid/ApplyDescription

Yeah, that’s no problem at all. What I’m curious about tho is how I’d separate ids from arrays/singular IDs and use them in the actual line when the data is pulled.

Here’s an example:

local Ok, Result = pcall(function()
	return DataStore:GetAsync(Key)
end)

if (Ok)
then
	-- Result will be the table you stored:
	-- local Array = { ['BackAccessory'] = {id1, id2, id3} }
	-- To access it, simply do:
	local BackAccessories = Result['BackAccessory'] -- This will be the dictionary containing the ids for BackAccessory.
else
	warn(('Could not load data for %s! (%s)'):format(PlayerName, Result))
end
1 Like

Alright! I can see how this is working out.

If so, it shouldn’t really be that much of a problem to get this up and running. Thanks for helping out!

1 Like

You’re welcome, let me know if you have other concerns in the future, if you’d like.

Good luck on your project.

1 Like