Changes to Hats and Body Parts

Hello all,

We are making changes in the next few weeks to the ROBLOX avatar and want to give you a heads up so you can update your games!

Client Changes

1) Hats → Accessories

All hats in the catalog will have their in-game class changed from “Hat” to “Accessory”. Accessory is a class that supports attaching to many points on the character, instead of always being attached to the head.

If you have scripts that check:
if obj.ClassName == "Hat" or obj:IsA("Hat"),
these will not handle accessories properly. You should update your scripts to use obj:IsA(“Accoutrement”). Accoutrement is the base class that both Hat and Accessory inherit from, so this will handle both Hats and Accessories. For example, most games have a script that cleans up dropped hats after a certain amount of time. You will need to update those scripts to handle Accessories.

If you need to attach or remove Accessories from your character with Lua, see the Accessory wiki page.

Another thing to note: If two matching Attachments are found the resulting Weld will be a child of the Handle of the Accessory. This differs from the legacy behavior of Hats where the Weld is always a child of the Head of the character.

2) Body Parts R6/R15 Split

It used to be that all body parts (right arm, right leg, left arm, left leg) were composed of a single CharacterMesh that was pasted into the character. To support R15, the format is changing.

The existing body part assets will be updated a new format composed of two Folder objects named R6 and R15. If you have a game that allows inserting of body parts, you may have to tweak your scripts to support both the folder format, and the old format of a single CharacterMesh.

blob.png

Web Changes

We will be splitting up Hats into a number of different “accessory” types on the website, like Shoulder Accessory, Hair Accessory, Waist Accessory, etc. If you have a game or Chrome extension or website, keep that in mind. These new types will show up on the Trade page, Avatar page, Inventory page, and catalog. This means that you will see items disappearing from your “Hats” and moving into other categories. Hats will also be labeled as “Accessory | Hat” in some places where they used to be labeled “Hat.”

Related Links

http://wiki.roblox.com/index.php?title=R15_Compatibility_Guide
http://wiki.roblox.com/index.php?title=API:Class/Accoutrement
http://blog.roblox.com/2016/09/the-r15-avatar-is-here/
http://blog.roblox.com/2016/05/stuck-on-you-roblox-avatars-get-attachment-objects/

33 Likes

If anyone needs to migrate their game to use the Body Parts format I added a code sample to the wiki showing how you would equip the new format to both a R15 and a R6 character.

6 Likes

className is deprecated, please use ClassName instead. :wink:

Anyways, to be actually constructive… Yay different types of accessories on the site!

9 Likes

In my game I use insertservice to load roblox hats and get the first child of the model loaded(which is always the hat, I dont actually search for the hat item, just getchildren()[1]), will the .AttachmentPoint data change at all? Is the only change for me basically that I need to expect “Accessory” instead of “Hat”?

1 Like

Using InsertService and inserting the accessory into the character will work just fine, the welds are automatically created. Steampunk Wings of Mechanical Destiny is already an Accessory class in the client, using this code worked fine to load it on an avatar.

local assetId = 356211143
local accessory = game:GetService("InsertService"):LoadAsset(assetId):GetChildren()[1]
accessory.Parent = game.Players.Player1.Character

6 Likes

I actually don’t place it on people, I place it myself on little soldiers. I adjust the CFrame of the hat handle with its AttachmentPoint and the mesh scale since my soldiers are tiny and then weld it myself to the unit’s body.

1 Like

The AttachmentPoint of any items already in the catalog will stay the same but the type will be changed to Accessory and new Attachments will be added.

You can use the AttachmentPoint as before or you can create Attachments for your characters and then weld the attachments together like this:

function weldAttachments(attach1, attach2)
	local weld = Instance.new("Weld")
	weld.Part0 = attach1.Parent
	weld.Part1 = attach2.Parent
	weld.C0 = attach1.CFrame
	weld.C1 = attach2.CFrame
	weld.Parent = attach1.Parent
	return weld
end

If you need to manually position the accessories you can do it like this:

function findFirstMatchingAttachment(model, name)
	for _, child in ipairs(model:GetChildren()) do
		if child:IsA('Attachment') and child.Name == name then
			return child
		elseif not child:IsA('Accoutrement') and not child:IsA('Tool') then -- don't look in hats or tools in the character
			local foundAttachment = findFirstMatchingAttachment(child, name)
			if foundAttachment then
				return foundAttachment
			end
		end
	end
end

local character = game.Players.LocalPlayer.Character
local accoutrement = game:GetService("InsertService"):LoadAsset(assetId):GetChildren()[1]
local handle = accoutrement:FindFirstChild("Handle")
if handle then
	local accoutrementAttachment = findFirstChildOfClass(handle, "Attachment")
	local characterAttachment = accoutrementAttachment and findFirstMatchingAttachment(character, accoutrementAttachment.Name) or nil
	local attachmentPart = characterAttachment and characterAttachment.Parent or guy:FindFirstChild("Head")
	local attachmentCFrame = characterAttachment and characterAttachment.CFrame or CFrame.new(0, 0.5, 0)
	local hatCFrame = accoutrementAttachment and accoutrementAttachment.CFrame or accoutrement.AttachmentPoint
	handle.CFrame = attachmentPart.CFrame * attachmentCFrame * hatCFrame:inverse()
	-- The accoutrement is now manually CFramed to the correct position
end
6 Likes

Thanks that clears up my question!

1 Like

The wait is finally over!

Can’t wait for this update!

1 Like

I currently try to find body meshes for R6 by using charChild:IsA("CharacterMesh") on all direct children of the character, do I need to start looking in a R6 folder inside of the character now? So both R15 and R6 data is in the character at all times? Or does this only apply when inserting packages?

Do all accoutrements have the same structure as current hats? Accoutrement -> Handle (Part) -> Mesh?

3 Likes

This only applies when inserting packages. CharacterMeshes will still be added to R6 characters as before.

Yes, that structure hasn’t changed.

2 Likes

Have any of you guys ever seen those package changers in-game?
Well, none of them will work with R15, only with R6.
I just managed to finish making a new one that is compatible with R15 :smiley:!

Unfortunately I won’t be able to release this until the GetAssetIdsForPackage function gets enabled.

EDIT: We’re live!

11 Likes

Progressive steps, awesome!

1 Like

I just enabled this. Great work on the package changers.

9 Likes

I’ve been waiting for this for a long time, thank you!

1 Like

Seems cool, can we expect hats to be weightless after this update?

(Didn’t mean to reply Letink, and I have no idea how to undo, sorry :c)

2 Likes

What’s going to be the limit of accessories on your character, and would it be for all accessories or per accessory category?

Also

Do you have specifics on how the JSONs these pages use are going to change? Most importantly (for me anyway) the InventoryHandler page.

1 Like

During the migration, the limits will stay effectively the same. You will be able to wear a max of 3 of any accessory type.

After the migration we are considering increasing the limits so you can wear one of each accessory type, but removing the 3 hat limit. Most combinations will be valid under the new accessory types, but we may have to create a few more accessory types to accommodate what users want to wear.

2 Likes

Wow you replied faster than anticipated, I edited in another question in my post.

Do you have the number of planned accessory types?

1 Like

There are 8 accessory types planned right now.
Hat
Hair
Face
Neck
Shoulder
Front
Back
Waist

5 Likes