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

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

This really helped me - just one problem. I applied this method to a click detector, and it works fine. But the only problem is that ALL players receive the model attached, and I only want it to attach to the local player. How would I go about doing this?

You should show code as well as your circumstances (e.g. type of script being used) so we know what you’re working with right now and further determine what the problem may be.

ClickDetectors pass the player who clicked it as an argument, so if you reference this player (and their character) you should generally not have any problems where effects are being given to everyone as opposed to one person. If it’s from a LocalScript, you can check if the passed player is equal to the LocalPlayer before proceeding with any actions.

Howdy, I’ve come to a problem:

Whenever the parent of an accessory is changed all of the welds are destroyed, I have no clue why.

Do I need to reweld all of the parts together every time the parent is changed?

EDIT: Yes, it absolutely needs to be scripted welds, im creating a custom part system where it welds them to the handle of the accessory.

This behaviour appears to be native to accessories. They don’t expect their their parents will get changed after they’ve been attached to a character; an ancestry change gives the assumption that the player intends to take the accessory off. Didn’t know all the welds break though…

Incidentally, you can actually skip the use of an accessory and directly weld your models/parts to the player. The only difference is that instead of having welding behaviour built in for you, you will have to create the welds yourself between the two attachments and model root.

Accessories are typically easier to use and allow you to take advantage of the engine but in esoteric or unexpected cases like this (reparenting) you can run into some issues and understandably need another solution that can give an equivalent feeling.

Check out this reply for the accessory weld creation code:

This is what Roblox does internally to weld accessories. If we take all that and apply it to a model:

image

image

7 Likes

how could you do this with a model?

See the post right above yours, I show how you can do this same thing with a model! The principles are essentially the same only that you have to create the weld between the attachment points manually.

1 Like

oh ok, ill try that, but how could i move the players WaistFrontAttachment? (im basically trying to put a body flashlight on the players left hip)

You won’t ever really have a need to move any attachments. Rigs come with lots of attachment placements in as many places as you can think of. If you don’t find the ones you need, you can create a new one and the above methods will work just the same, whether you use an accessory or a model.

In your case of wanting to put a body flashlight on the player’s left hip, R15 rigs already have a left hip attachment. It’s called LeftHipRigAttachment and can be found in the LowerTorso.

If you need to offset the flashlight a bit, you can move the LeftHipRigAttachment that you add to the body flashlight. Welds will snap together attachments so you just need to move the attachment you add to your model so that when the attachments snap together, the flashlight is placed comfortably on the character’s left hip.

2 Likes