What's the most efficient way to attach model to player's hand/anything else

Could you supply other information about this? I still don’t have enough to work off of.

  • What is the hierarchy of the model?
  • How do you attach this to the player? What’s the code you’re using?
  • Can you confirm that a matching attachment for the handle exists in the character?

I’ve provided a small repro so you can check if what you’re doing matches exactly with the tutorial or my given implementation. Following through is important, including with naming choices.

Artificial Tool Repro.rbxl (49.2 KB)

The accessory is located in ServerStorage and the code I used is in StarterCharacterScripts.

6 Likes

Also check if it is anchored or not.

2 Likes

Do accessories work for shoes or boots? I was wondering if I could do this for my Ice skating system. Thanks!

This will work for any limb that has attachments in them. When you use AddAccessory, the Humanoid will line up attachments between the accessory’s handle and one of the same name within the rig, then weld the attachments together. I do recall there being attachments in leg limbs so absolutely it would.

2 Likes

How would you change the grip?

If you need to change the grip, you would need to change the properties of the accessory and then reattach it to the player. You may lose some of the instant offsetting magic that a Tool instance provides primarily because once you change values around, the joint between the attachments may break.

1 Like

I wish I knew this method way before but I’ll keep it in mind for future use. Thanks for showing us this!

How would I do this with a tool/model consisting of multiple parts? I’ve tried things such as parenting the parts to the handle but only the handle is affected.

1 Like

You will need to weld all extra parts to the handle. Parenting will only change where the part is located in the hierarchy but it doesn’t have any implicit behaviours. You can find several resources, plugins and code samples to help you perform this. Studio also has a built-in welder via the constraints menu.

1 Like

Hello! How would I go about moving the right arm using this implementation? What I mean is when you use a normal tool it automatically moves the arm up so I would like to copy this behaviour using this method. Do you do it with animations?

Yes, you would have to do this through an animation just like how it’s done for regular tools. The Animate script accounts for an equipped tool and then plays the generic tool idle animation: this behaviour will have to be modified, mimicked or done in another way.

I do not have an edit of the Animate script handy in this case. You can consider making use of BindableEvents and RemoteEvents to accomplish a mod similarly to how the Animate script checks for a tool before playing the hold animation.

1 Like

Awesome! Never knew about this. Thanks colbert.

1 Like

btw colbert can we do that with models?

1 Like

If you were to put a model in an accessory, the requirements don’t change. All that would happen is that your parts now belong to a model instance and are a generation down in the hierarchy. So long as you still have a handle outside the model and the parts are welded to it, you’re good.

If what you meant by “can we do that with models” as in foregoing an accessory and instead directly applying models to players, you can do that as well. You’d virtually follow the same steps including adding attachments so it’s easier to position your models. Main difference is you’d have to handle the welding yourself. You can use the following code to do that:

local accessoryWeld = Instance.new("Weld")
accessoryWeld.Name = "AccessoryWeld"
accessoryWeld.Part0 = YOUR_ACCESSORY_HANDLE
accessoryWeld.Part1 = LIMB_TO_ATTACH_TO
accessoryWeld.C0 = accessoryWeld.Part0.ATTACHMENT_NAME.CFrame
accessoryWeld.C1 = accessoryWeld.Part1.ATTACHMENT_NAME.CFrame
accessoryWeld.Parent = accessoryWeld.Part0

Let me know if this explanation is too confusing, might be able to create a picture tutorial for that as well.

EDIT 12/03/2021: Use RigidConstraints to snap accessories together by their attachments instead.

6 Likes

that mean if in the model its still have a handle it will be good? and also does the model need to be setPrimaryPartCFrame also what is the best way to position it (when there are no model) because its kinda hard and poopey to position it also the explanation is somehow confusing and the model dont actually works (i used model because it has texture insibe so i couldnt union it)

I’m not too sure I understand what you’re asking here or if there any inferences being made. To be clear: handles are just regular parts. Some objects on Roblox require this specially named part for various actions, but there doesn’t always need to be a handle so long as you’re willing to do all the welding yourself (e.g. accessories, tools, so on).

No. Unanchor all the parts, weld them to a root (typically might be your PrimaryPart which is the Handle) and they will automatically have their positions updated when the root part moves.

That’s why the attachments exist. When you weld two attachments together, ideally they should line up, so the model is snapping at the position of the attachments. You can see in the picture tutorial I had up that the two attachments eventually connect, leading to being able to grip the tool the way the character does in the last screenshot.

In what way?

Which model and also in what way?

1 Like

oh thx you for the explanation but i have manage to understand in a better way thx for the help i appreciate it btw the C0 and C1 is confusing

1 Like

Honestly I still find C0 and C1 confusing myself. They’re meant to be offsets for Part0 and Part1 since not setting them will make the parts snap together in the middle. In this case, I’m using both accessories to “offset” the parts when they get attached to the player.

It’s better to see how the parts behave when you actually start welding. An explanation really doesn’t do those properties too much justice.

2 Likes

How can I change the position to where the knife is attached to the hand?

This has been asked and answered earlier: please do make sure to read through the replies to see if your question’s been asked before!

1 Like