Changing scale and offset of accessories

After exhausting Google, the DevForum, and the Roblox Studio Community Discord without finding any clear answers, and spending the entire day trying to figure this out, I finally made some progress on manipulating accessories via scripting!

A lot of the difficulty comes from the still relatively-recent changes with humanoid descriptions and how to access the player models. I’ve been fairly comfortable with doing that, but I’ll recap some of it here for anyone who is still struggling with outfitting players or NPCs:

Currently, the way you want to access a player’s character model is through the humanoid description object and the functions related to it, instead of trying to access it directly through the workspace. The newer documentation on it is pretty clear and helpful. For instance, in my current project I’m making some NPCs for the player to interact with so I used the Rig Builder plugin to insert some generic Rthro models into my game.

image image

I have them placed where I want in the workspace, then I also have in storage some HumanoidDescription instances that have all the information needed to deck out my models. The main script of my game then applies these descriptions to the models using the :ApplyDescription function.

image image

Now all this works beautifully for setting up my NPCs, but some of the accessories don’t scale correctly for the models they’re put in.

Changing the body scale properties can help some for maintaining proportions, but then the accessory scale or offset may still not be quite right.

image

You can see here how much the hat is clipping into the head. I played around with things for a while, trying to adjust the AttachmentPos of the accessory didn’t do anything, neither did changing the position of the individual attachments. I could move the accessory around by changing the position and size in the handle, but none of those changes would stick when testing.

Finally, I found out that the accessory’s handle has a SpecialMesh part with both offset and scale values. Those can be changed via scripts and the changes DO stick in the actual game.

image image

Adjusting those ends up giving you some results that look much better!

image
image

So the TL;DR version is if you want to change scale or offset of an accessory with scripts, you need to change the values of Accessory.Handle.SpecialMesh.Scale and Accessory.Handle.SpecialMesh.Offset.

I just hope this helps out someone else struggling with the same problem!

9 Likes

You still need access to the character model to apply a HumanoidDescription in the first place. HumanoidDescriptions are not a replacement for accessing the character model, they are a way to help in changing the appearance of an avatar. In some cases the appearance changes you want cannot be facilitated with HumanoidDescriptions and so you must modify the character directly.

Even then, if you ignore HumanoidDescriptions, if you want a player’s character model you shouldn’t ever be doing it through the Workspace. Player objects have a dedicated Character property which contains a reference to their character model. This should always be used. If you rifle through the Workspace and an instance happens to share a name with the character, you could index the wrong object and this can lead to problems in your code.


In general I’m curious to know how applying accessories with HumanoidDescriptions gave you improper fitting via their size or position. Typically always works in my case. Do you have any media to augment your thread, such as a video or picture of the problem happening and how applying this tutorial might resolve that problem?

When I run into problems with accessories, I usually turn them into MeshParts and then modify the attachment position in the accessory as needed to adjust their position.

1 Like

The thing is, I was using accessory assets that already existed in the avatar store in order to build my NPCs, so I didn’t have direct access to the accessory info itself in order to modify things. I’m sure there is a way to just copy the asset into my game, but in this case I just used the asset id to get it directly from Roblox since I could just plop the id into the humanoid description.

The character property is still a reference to the model in the workspace. That’s what I meant, that even even using .Character accesses the workspace model and modifying that model directly usually does not stick. I’ll go back and add some images to show what I was talking about.

In what cases do the changes you make on a Character model “not stick”? They do, unless you’re using any API or objects that override specific elements of the Character. In this case you can just change the order of application or change the approach. I don’t think this is particularly accurate.

This is the one problem that people run into a lot when they’re trying to give player characters custom clothing or accessories. If you try to add an accessory directly to the model, it won’t “stick” because it is overwritten by the humanoid description. I think that was the same problem I was running into with trying to change the attachment position or accessory size-- it was changed, but then overwritten by the SpecialMesh properties.

In my searches, the documentation doesn’t give any good accounting of how and in what order properties are assigned, so I had to play around with it myself. This is just the solution I found. If you’ve got a better one, please post it so that other people having the same trouble actually have a source to check.