I know I use a WeldConstraint to weld it. The question is how do I get the Accessory in the right relative offset position to weld. The attachments btw are pulled straight out of the default character in studio.
Make an attachment inside your handle. Give the attachment a name. This name should match an attachment inside the player’s character of which you wish to align with your attachment.
All characters have a humanoid which is why you state this in a LocalScript in StarterCharacterScripts:
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid
Humanoid:AddAccessory(game.Workspace.AccessoryName_)
I have another question that came up. The accessory Handle is making a TouchTransmitter anytime I parent it to something in workspace, so if my character Touches a Humanoid, then the accessory gets yoinked from my character and gets placed on the Humanoids character.
Nevermind I figured it out. Anytime there is a BasePart named “Handle” in an accessory it will create the TouchTransmitter. All I have to do is rename “Handle” to “handle”.
You could also just turn off CanTouch on the part. TouchTransmitter facilitates Touched events and it’s illegal to add one to a BasePart that has CanTouch off (a warning will be sent to the console). Depending on your circumstances you could also destroy it on the same frame its created by checking for a new instance of the TouchTransmitter class but that’s less elegant than just turning off CanTouch.
Okay thanks. I tried deleting the TouchTransmitter when it gets created using a ChildAdded event but I got a warning that says “Something unexpectedly tried to set the parent of TouchInterest to NULL while trying to set the parent of TouchInterest. Current parent is Handle.”
Setting CanTouch works good and is less hacky than renaming the Handle, I’ll use that!
You would need to defer the destruction not to get that error.
ChildAdded:Connect(function (child)
if child:IsA("TouchTransmitter") then
task.defer(child.Destroy, child)
end
end)
This does mean more connections though and that’s not good for memory management especially if you don’t predictably know how many accessories may end up needing that deletion. CanTouch false is definitely the better route here.