Accessory Based Items, Clothing & Addons. [UPDATED]

Introduction

Hi there, my name is TreySoWavvy and I am an LUA Programmer and a 3D Modeler.
I have noticed a lot of new/old developers are switching over from 2D to 3D aspects in their gameplay such as 3D armor, holstered weaponry, and other addons to make their characters pop. This is a tutorial on the 2 methods I use for offsetting models from the body of the character. This can be used in a variety of applications from FPS games to Fantasy RPG ones (in other words my game and most likely yours) Below are some examples of the applications:

  • Weapons meant to be visible on the body (swords, pistols, lightsabers)
  • Custom 3D Armor & Clothing. (Attack on Titan Cloaks for example)
  • Addons / Accessories for aesthetics (holsters, bandages around the arm, etc)

The Concept
I want you to remember that there are two types of Accessories: Static and Dynamic.

  • Static Accessories (Welds): Don’t move and welded in place until changed. Good for clothing and other addons that arent meant to be moved or manipulated directly.
  • Dynamic Accessories (Motor6Ds): DO move and are meant to be manipulated directly. Good for weapons that can move, slide, and rotate while attached to the body. (i.e a sword being gripped by a player.)

Understanding Accessories And How They Work
Accessories are an instance that attaches a premade model to the body at a fixed offset determined by 2 Attachment Instances. 1 Attachment is owned by the Accessory itself, and the other is owned by the instance the Accessory is Attaching itself too. The prime example would be a hat and the character wearing it. Roblox will then automatically generate a Weld Instance using those two Attachments as C0 and C1 offsets, essentially doing the work for you.
NOTE: This automation only applies to Static Accessories, I will provide a method to doing this with Dynamic ones

Initial Setup | Manipulating Attachments In Rigs
The benefit of using a Rig’s attachments is that you can create your own and are not limited to the defaults that come with the rig. This essentially means you can have an infinite number of attachment points although having more than a key few is a redundant practice. Roblox’s R6 and R15 rigs come with a set amount of Attachments used by the catalog items and body joints which we will be using today. If you feel like adding your own later on by all means go crazy.

RobloxStudioBeta_rNkOwaILff
1.) Constraint Details: Allows you to see attachments and constraints in a 3D space. Turn this on to see what you’re working with. (Attachments are green balls by default)
2.) Draw On Top: Renders those attachments and constraints on top of the instances they are parented to. Makes selecting them so much easier.

ATTACHMENT NOTE: Do NOT have multiple attachments with the same name, results may be unsatisfactory. Use concise names you can refer to and make sense.

Now that Constraint Details is turned on, your Rig should look something like this with the outer attachments shown:
RobloxStudioBeta_J82eeB3Ijh
If you have Draw On Top enabled, It should show the attachments hidden inside the body parts themselves like so:
RobloxStudioBeta_kfG7Zh4gaB
Roblox covers most of the necessary attachment points for you already, but should you need to add your own:

  • Add an Attachment to a body part.
  • Give it a unique name that you’ll use inside your accessory.
  • Use the Default Move tool to offset the attachment from that body part in whichever way you need! Plugins like F3X cannot manipulate constraints!
  • Set the Attachment’s WorldOrientation to (0, 0, 0)
    Why should I keep the WorldOrientation Property at (0, 0, 0)?
    It’s actually simple. Roblox uses the properties of the Attachment to offset your Accessory from the body. Since the Attachment Orientation won’t be the same as the Accessory’s Orientation, you are essentially creating a rotation for your Accessory! In most cases, we don’t want this!

Static Accessory Setup
Below is the proper checklist on how to properly set up / convert a model into an accessory, Using the F3X plugin.

  • Make sure all the parts are Unanchored. We don’t want the player stuck in place.
  • Make sure collisions are turned off for all parts. We don’t want the weapon colliding with the environment.
  • Make sure at least one of these parts is named (Handle). (Similar to creating Tool Objects)
  • Right Click on the Handle Object and create an Attachment Object inside of it.
  • Create a new Accessory Object, and parent all parts to the accessory.
  • image
  • Congrats, Now you have created your own accessory in Roblox.

Dynamic Accessory Setup

  • Repeat all the steps above for Static Accessories, Except keep all the parts grouped as a model and not an accessory.
  • image
  • The reason is that Roblox will override ANY welds (and motors) you create for that accessory by default and make their own, so we have to use a Model Object and simulate an Accessory Instead.

Setting Up The Offset
I’m going to attach this spear, to the back of this rig at an angle shown by the red line.
RobloxStudioBeta_HmDxSMFqLw
Move your spear into position and give it the proper offset using editing tools Without breaking the welds holding the parts together. F3X does this nicely but Default Build Tools can work too.


If you remember in the earlier screenshot, the Handle Object had an Attachment inside of it, we will be using that attachment now to tell Roblox to keep this spear at this position on the back of a rig.
To properly setup an accessory attachment so the rig can use it, you must:

  1. Rename the Handle’s Attachment to match the name of Any Attachment within the body parts of the Rig. Can be the default ones shown above or one you created.
  1. Copy and paste the WorldOrientation from the Body Attachment → Accessory Attachment so they match rotations.
  2. Copy and paste the WorldPosition from the Body Attachment → Accessory Attachment so they match positions in the world.
    RobloxStudioBeta_y4tDjDHAl5
  • Now Both attachments share a position and a rotation.
  • Congrats, you have effectively created the C0 and C1 for the Welds we will use later.

IMPORTANT NOTICE: Remember to make sure that both attachments have the same name, if the names are off it won’t weld, and if it’s the wrong attachment it will look for it and attach it there instead.

Adding Static Accessories To The Character
Static accessories require minimal changes beyond this point, all we have to do now is write some code to give a copy of this attachment to a character. Once the accessory is added it really doesn’t require any further changes, like most of Roblox’s Catalog items. In order to accomplish this, we will be using the Humanoid:AddAccessory(Instance) method. It takes an Accessory as its first argument and handles everything else from there.
Here is a very simple script used to give me the spear when I respawn:

--| When the player respawns, Use AddAccessory to give them the spear owned by this script.
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Character.Humanoid:AddAccessory(script["Royal Guardsman Spear"]:Clone())
	end)
end)

The result of Static Accessories will essentially be the same as normal Catalog ones. If this is what you needed then this tutorial is done for you. For the rest of you who need more dynamic and controlled accessories, keep reading.

Adding Dynamic Accessories To The Character
For the rest of us more experienced scripters and game designers, sometimes we need more control over our accessories that a simple weld can’t really handle. My workaround for this issue is simple, using a Model Object and simulate an Accessory Instead and replacing the Weld Roblox creates with a Motor6D instead. The reason I do this is to give me the option to animate the weapon ALONGSIDE the character using it as well. This is especially good for weapons that you wish to move along the body i.e sliding the spear grip relative to the hand forward or spinning a knife in my hand.

If you’ve already worked with Motor6Ds then you know what I am referring to here, we are taking THAT process and making it slightly easier to manage. The benefits of dynamic accessories are that when they are attached to characters, you can animate them alongside the character and make your animations more fluid and realistic. Below is a good function I found/remade that creates Pseudo-Accessory (as we will call it) using the Model and Motor Instances:

local function AddCustomAccessory(Model, Accessory)
	Accessory.Parent = Model
	local HandleAttachment = Accessory.Handle:FindFirstChildOfClass("Attachment") -- Find accessory attachment
	local CharacterAttachment do -- Find character attachment
		for _, v in ipairs(Model:GetDescendants()) do
			if v.Name == HandleAttachment.Name and not v:FindFirstAncestorOfClass("Accessory") then
				CharacterAttachment = v
				break
			end
		end
	end
	
	--| Destroy any previous welds.
	for _, v in ipairs(Model:GetDescendants()) do
		if v.ClassName == "Weld" and v.Name == "AccessoryWeld" then
			v:Destroy()
		end
	end
	
	--| Replace the weld with a Motor6D instead.
	local AttachmentWeld = Instance.new("Motor6D")
	AttachmentWeld.Part0 = CharacterAttachment.Parent
	AttachmentWeld.Part1 = HandleAttachment.Parent
	AttachmentWeld.C0 = CharacterAttachment.CFrame
	AttachmentWeld.C1 = HandleAttachment.CFrame
	AttachmentWeld.Name = Accessory.Name
	AttachmentWeld.Parent = Accessory
end

By using this function on a Pseudo-Accessory, we can essentially create our own accessories without the actual object class. I recommend in your game you have a folder inside the character model that stores these “Accessories”. Since they are models they don’t need to stay parented DIRECTLY to the character unlike accessories, so you can have some organization there.

Conclusion
Accessories are a useful approach to game development that should be encouraged to intermediate developers to look into for various aspects of your gameplay, they are a cleaner and more organized method to welding things to your character and allow you to set, get, and change the offsets easily without keeping a bunch off offsets stored somewhere. Psuedo-Accessories provide more functionality and allow you to properly animate your tools with your characters adding more pop and realism.

If you have any questions and concerns about this guide for game application feel free to respond to this thread and I’ll be happy to help you.

Changelog

[3/4/21]

  • Added proper formatting, cut out a lot of unnecessary details and humor.
  • Fixed my unprofessional way of speaking in this tutorial, I apologize to whoever read V1.
  • Added the concept of “Psuedo Accessories”, and explained how they work.
146 Likes

Wow! Great tutorial and I might use it soon!

4 Likes

If you’re going for a quick swap mechanic (i.e sword from back to hand or vice versa) I highly suggest you parent the accessory to a service where physics aren’t applied like ReplicatedStorage that way so you can change the attachment properties without fear of the weapon falling apart :slight_smile:

7 Likes

Amazing info! How would you do this with a specially animated pose? (Think Critical Strike)

4 Likes

Will this worked with animations that use attachments?

Hi Lillian, sorry for my late response as I am on vacation :slight_smile:

This all depends on your animations. As stated above I suggest the Dynamic Accessory approach. When animating a rig with a weapon(s) attached to it. The animation editor (Default / Moon Suite) recognizes the Motor6D used to attach the weapon/tool to the hand.

This is why we use Motor6D over regular welds for Dynamic Accessories. Moon Suite will properly allow you to animate the tool if it’s welded (with a motor6d) to a rig if that answers your question.

Do you have any examples or could further elaborate on the Dynamic accessories? I’m not really that good in the animation sector.

Dynamic accessories essentially are any accessory that is attached to the character with a Motor instead of Weld. If you’ve ever played any sort of melee combat game you’ll notice with the animations that the weapon can slide, rotate, flip, and overall move in the hand of the person using it.

An example of this would be a spear, now animating a spear would require you in most cases to hyperextend the arms outward in order to get a “good jab effect”. But by using a Dynamic accessory over a static one, you can essentially slide the spear along with the user’s hand (in the animation editor) and thus increase the range of your jab while adding more aesthetics to the animation itself.

A weapon is never rigidly attached to your body in the real world, and the motion is fluid, welds are meant to be rigid which can be counter productive in some cases.

1 Like

Here is an example of a spear jab; The spear is a Static Accessory. notice how the spear stays locked in at that offset? The spear’s range is determined by the length of the spear, and the distance the arm travels.

Now, a Dynamic Accessory allows you to slide that spear forward during this attack and give yourself more range / Control over the motion of the spear. Static accessories remove that control and the spear’s motion is determined by the hand it’s welded too.

So, TLDR;
Dynamic Accessories: You can control the motion of the weapon/accessory
Static Accessories: Once it’s welded, it’s welded.

3 Likes

Thank you. It’s much more clearer now!

I’m am using a Motor6D joint to attach a sword to a player’s lower torso because I need to make sheathe and unsheathe animations, however, because I’m trying to blend them with a walking animation sometimes the sword and the hand are displaced, would anyone recommend switching the parent of the sword to the hand after you unsheath it?
In that way, if I make an animation of running with the unsheathed sword it doesn’t juggle everywhere because it’s parented to the lower torso, instead, it moves with the hand but will that cause problems?
Example:
https://gyazo.com/36c2b7948523e716159184f2fdb12003
If the player Is moving sometimes the sword moves out of the hand.
IF I switch the parent to the hand after you unsheathe the sword It could clip and rotate in weird ways??
It seems that after slowing it down frame by frame the sword tries to return to its original Motor6D position between animation transitions before doing the animation, which causes displacement?
Does anyone know how to fix this?

3 Likes

Will it work with blender animation as well??

Assuming you export the rig properly it should work with Dynamic accessories, static ones most likely not since the blender export plugin doesn’t recognize welds as joints.

1 Like

In my game SkyClash, I do the following for sheathing / unsheathing:

    • Parent the accessory to an area where physics are not applied and updating of motors doesn’t take place. (A folder inside Replicated Storage is perfect for this, call it TempStorage)
    • Change the Properties of the accessory’s attachment point while still parented to that folder. (Attachment’s Name, Orientation, and Position)

3 - Reparent the accessory back to the original owner. This will more or less be done almost instantaneously and users won’t physically see it disappear if done correctly.

Try this approach and you should be able to clean up any issues you may be having. Let me know how it goes

3 Likes

Thanks, It worked! :star_struck:

Do you have a example of the attachment script that attach tool model to the left hand and right hand like dual wield sword or lightsaber?

In the tutorial, I have this function called AddCustomAccessory(Model, Accessory)
It takes the character as the first argument and the accessory as the second.

The function:

local function AddCustomAccessory(Model, Accessory)
	Accessory.Parent = Model
	local HandleAttachment = Accessory.Handle:FindFirstChildOfClass("Attachment") -- Find accessory attachment
	local CharacterAttachment do -- Find character attachment
		for _, v in ipairs(Model:GetDescendants()) do
			if v.Name == HandleAttachment.Name and not v:FindFirstAncestorOfClass("Accessory") then
				CharacterAttachment = v
				break
			end
		end
	end
	
	--| Destroy any previous welds.
	for _, v in ipairs(Model:GetDescendants()) do
		if v.ClassName == "Weld" and v.Name == "AccessoryWeld" then
			v:Destroy()
		end
	end
	
	--| Replace the weld with a Motor6D instead.
	local AttachmentWeld = Instance.new("Motor6D")
	AttachmentWeld.Part0 = CharacterAttachment.Parent
	AttachmentWeld.Part1 = HandleAttachment.Parent
	AttachmentWeld.C0 = CharacterAttachment.CFrame
	AttachmentWeld.C1 = HandleAttachment.CFrame
	AttachmentWeld.Name = Accessory.Name
	AttachmentWeld.Parent = Accessory
end

What I do for dual wielding, is simply take a copy of the lightsaber, and mirror its properties but for the other hand. For example your position and offset data for a right handed lightsaber will be identical to a left handed one, the only difference is instead of naming the attachment RightGripAttachment (the default one in the right hand), you would name it LeftGripAttachment instead.

This is how you would essentially mirror the right handed accessory to the left.

By parenting both accessories, one gets welded to the right hand, and the other to the left. Now you have dual wielding.

1 Like

Ah okay but where this script go in?

Since I do not have a clue as to how you are scripting your system I couldnt say, but relatively speaking the advice i can give you is this:

  • Find a way to determine which weapons are dual wield-able
  • Within your script(s) that configure / setup the accessory, determine if the tool / item is duel wield-able and write an if statement to check it.
  • if (CanDualWield) then → Clone the accessory, and change the name to be the opposite of whatever the initial attachment’s nameis
  • RightGripAttachment ← → LeftGripAttachment, and so on.
2 Likes

Hello, I was recently trying to recreate this (Full on armor rather than a spear) and I’m wondering where the script and the model goes? (Static accessory)

Edit: Scratch that i found out. Great tutorial! Many thanks.