How do I attach an accessory to the player

I tried to make a script that, when a player joins it takes the accessory and puts it on the player.


local player = script.Parent.Parent
local character = player.Character

wait(3)

local team = player.Team
local teamitems = team:GetChildren()

for each, i in teamitems do
	local hat = i:Clone()
	player.Character.Humanoid:AddAccessory(hat)
	local attach = Instance.new("Weld")
	attach.Name = "AccessoryWeld"
	attach.Part0 = i.Handle
	attach.Part1 = player.Character.Head
	attach.C0 = attach.Part0.Connect.CFrame
	attach.C1 = attach.Part1.CFrame
	attach.Parent = attach.Part0
	print(hat.Parent)
end

But rather than put the accessory on the player, it just stays in its position and doesn’t attach, how do I attach the accessory?

2 Likes

What you do is you name the hat “Handle” and parent the hat object to the accessory. You then make an attachment, and name it based on what attachment you want it to connect to (look up "full attachment rig …rigtype). Then after that’s done, parent it to the rig with the attachments in it. To edit its position, you just take the attachment in the hat object, activate the move tool (the attachment move tool is broken), and there ya go!

Plus, no attachment code. Just do a :Clone() and parent it!

1 Like

InsertService:LoadAsset(assetID) might help!

Use this function, and write the following script:

local asset = insertservice:LoadAsset(assetID)

for _, v in asset do
if v:IsA("Accessory") then
v:Clone().Parent = player.Character
end
end
3 Likes

AddAccessory alone should suffice, it connects all of the required attachments for you.

2 Likes

Thats all good, but I am still not sure how I would go about making the attachment, can you just explain that a bit

1 Like

you put the attachment in the handle, and you name it to whatever attachment you want it to stick to in the character. For something you want in the torso, you can name it something like, “WaistCenterAttachment” and move it up one stud for it to go in the perfect spot