The idea here is rather simple.
I have an avatar editor in my game, which allows for players to edit their avatar, however, the problem with this lies with the fact that I’d need a way to save players outfits.
I quickly found a rather easy way to save shirts and pants but when I got to accessories the problem became much greater, as the method I used to save shirts and pants causes major errors when trying to adjust it to accessories. It also simply isn’t elegant, the player can have a completely arbitrary amount of accessories and this method just doesn’t sit right with me.
You can see the method I had been using below
function SaveShirtAndPants(plr,outfitname)
local char = plr.Character or plr.CharacterAdded:Wait()
local urlpants = char:WaitForChild("Pants").PantsTemplate
local urlshirt = char:WaitForChild("Shirt").ShirtTemplate
-- print(urlshirt)
-- print(urlpants)
SaveOutfit(plr,urlshirt,urlpants,outfitname)
end
The problem also applies to animations and packages (and probably some other things like layered clothes)
I would normally use HumanoidDescription, then serialize HumanoidDescription to save the data, however HumanoidDescription does not actually reflect what the actual avatar in game looks like, it reflects the players avatar from the roblox website.
It is possible to append HumanoidDescription to reflect what the actual in game avatar looks like, then save the description like that and create a new instance for loading and use ApplyHumanoidDescription. This works very well for things like packages, animations, etc. But it’s not as simple for accessories, they’re separated into groups of accessories, i.e “Waist accessories” have a different value from “Hair accessories” and I would like to be able to avoid having to spam a lot of else if statements to get around this.
So at this point I’m somewhat stumped, I know that this is possible since I’ve seen other games do it, but for me at this point I think I need a little bit of help, if anyone has any better ideas than using HumanoidDescription please let me know! Or if anyone knows if I’m using HumanoidDescription wrong then that’d also be great.