I need to be able to save the appearance of a character, and then later load and set that appearance.
All things relating to the character appearance, such as accessories in the form of ‘hats’ or clothing, I can do just fine.
What is giving me trouble is the R15 meshparts for the body.
I had originally forgotten that a meshpart MeshId can not be set during a running game, and thus wasted a lot of time on that
So then I used…
local info = game:GetService("Players"):GetCharacterAppearanceInfoAsync(player.UserId)
info, holds the following categories…
bodyColors
assets
defaultPantsApplied
defaultShirtApplied
playerAvatarType
scales
So, the assets sub category is the only one that should have the characters body information
Now this is where it gets confusing…
If I have a default R15 character, the only thing I get in assets is
“Pants” (I don’t want to be nakey) with the asset id number.
there is nothing referencing the default meshparts for the body.
If I have my normal avatar, which is a character composed of multiple packages, what I get in assets is
“RightArm”
“LeftArm”
“RightLeg”
“LeftLeg”
“Torso”
each one of these has an asset id.
if I use InsertService:LoadAsset I get a model for each of these, and iterating through the model I find several folders, R15 being one of them, thus I can iterate through the R15, and find the meshparts for the body, such as the Torso model, has an R15 folder, and in that folder it has UpperTorso and LowerTorso. (One annoying thing, is that these parts can be referenced in lua script, but if you try to parent them to workspace, or a folder in workspace, then do not exist, such as if I try to parent the model from InsertService to workspace, the model shows up, but with empty folders, all empty except the R6 which holds one animation obejct)
So with an avatar using package parts, I can get the mesh parts (though the attachment for the Root joint is at the wrong position in the ‘Torso->R15->LowerTorso’ object
What I am thinking is this…
When a player loads a saved character, I need to totally rebuild their character with a default roblox character, without killing them (I have no idea how to do this)
Then once they are default, I can look through the saved id numbers for those packages such as LeftArm, RightArm, Torso… etc… and if they exist replace the default mesh body parts with those.
Then I would need to get the attachment cframes from my saved data (since I can’t trust the ones from the packages, being that RootRigAttachment was the wrong offset) and apply those to the attachments
Then have humanolid do a BuildRigFromAttachments.
So my questions are as follows…
-
Is this how it should be done? Or is there a alternative, or simpler way to save and reload a player’s character?
-
How do I get the default meshparts while in a running game, since I have no asset id’s for them?
-
For a BuildRigFromAttachments I need to remove the old parts and have the new parts in the character, so how do I do this without killing the character?
Thanks for any help on this.