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

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

oh ok, im using r6 so it would be like this:


also, how would i create a new one?

Ooh, gotcha. R6 rigs do not have hip attachments so you would have to make new ones. If you’re using StarterCharacter you can set up the attachments in Studio but if not then you’ll have to use a script to get that created whenever the character spawns. Just use Instance.new and make a new attachment, modify its properties and then parent it to the Torso.

local leftHipAttachment = Instance.new("Attachment")
-- set its properties and whatever
-- most important ones are name and position
-- position is relative to its parent, so small offsets like 0.5 work
leftHipAttachment.Parent = Torso
1 Like

what do you mean by this? also following the steps that you posted above (post 43) nothing worked for me, and I want this to appear for every player, so would getting the character by using workspace.F0xBirdman only work if im in the server? also, how would i get the players torso through a server script? EDIT: The LeftHipAttachment creating worked, but it was through a local script

These are just sample models, code and guidelines to follow, not things you should copy and paste right into Studio expecting them to work. They lay down the principles of how to accomplish this but the expectation is that you tailor the code and such to your game’s needs. You can also do some searches and tests if you’re unsure on certain things. :slight_smile:

If you want to be able to add the flashlight to all characters, then these will help you get it done:

You can also get players’ torsos via that last one. Encourage you to make an attempt using these existing resources first, including some of the code I’ve provided in the thread. :slight_smile:

Also regarding your edit, you should be creating the attachment in a server script.

3 Likes

I know this thread is old but… the question and your answer with the screenshots is on the money. Been trying to solve this for a few days now.

  1. Humanoid:AddAccessory(clonedAccessory)
  2. Make sure the clonedAccessory has the same Welding as where you want the part to weld to

Now I can move onto the next part of my game.
THANK YOU!

1 Like

rename the handle- or where you want your player’s hand to be holding the weapon- to “Handle” (yes, with the capital H.)

1 Like

I had some problems with it too, I spent like half a hour trying to find out what was wrong. I didn’t name it handle…

2 Likes

Hey! 4 years later meanwhile :smiley:
I want to do this with a model i quickly made, its all made from parts. This means it does not have a mesh, so how should I do this then? And, does it also need a handle if its on a head?
image (7)

I hope someone still answeres this after 4 years :laughing:

These days, the best way you can weld a full model to the player’s head is to use a RigidConstraint or WeldConstraint to attach your model to the head. Your model should have a part that you can use as a reference; all other parts should be welded to this main part which is in turn welded to the head.

That being said, if you want to use the accessory method, it’s still available to you. The only difference is that yes, you still require a Handle part, but you can weld the rest of the parts to that handle. Roblox is less kind to multi-part accessories than tools but it’s there.

1 Like

Never worked before with RigidConstraint and WeldConstraint etc. but i will try and find out, thanks!

You can also use Motor6D if you want to animate the parts.

The parts of the model of the player limbs?

You gotta weld all the parts inside the model first then place the model inside of the player, create a Motor6D and set the Parts to the model’s main part (or whatever, the handle) to any body part of the character

1 Like