Hey I have a bunch of military accessories and I want to attach them to the player with scripts but I just don’t know how to.
Here’s what I want it to look like:
Your question is a little vague, you mean add those accessories when player join your game maybe?
When player joins, on character loading, run a loop with all the accessories you want to attach to the players, and use Humanoid:AddAccessory()
each iteration
AddAccessory()
Something like this:
local FolderWithAccessories = game.ServerStorage:WaitForChild("AccessoriesFolder")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
player.CharacterAppearanceLoaded:Wait()
for _, accessory in pairs(FolderWithAccessories:GetChildren()) do
if accessory:IsA("Accessory") then
char:WaitForChild("Humanoid"):AddAccessory(accessory)
end
end
end)
end)
Its not working and there’s no errors in the output so I’m guessing this has something to do with the attachments since this accessory isn’t from the catalog and I’m guessing it doesn’t have any attachments in it. I’ve never had any experience making attachments for accessories that aren’t hats so if you could teach me that would be awesome.
You created those accessories? The name of the attachment in the handle should be the same as any Rig’s attachment name, you could show us the name of the attachments
Yeah theres no attachments in it. (I purchased these accessories)
Add an attachment, named as the proper attach point in player character, and its gonna work
Updated code, to check if theres attachment and their names:
local FolderWithAccessories = game.ServerStorage:WaitForChild("AccessoriesFolder")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
player.CharacterAppearanceLoaded:Wait()
for _, accessory in pairs(FolderWithAccessories:GetChildren()) do
if accessory:IsA("Accessory") then
if accessory:FindFirstChild("Handle") then
for _, attch in pairs(accessory.Handle:GetChildren()) do
if attch:IsA("Attachment") then
warn("Attachment Name:", attch.Name)
end
end
else
warn("the accessory doesnt have a Handle")
end
player.Character:WaitForChild("Humanoid"):AddAccessory(accessory)
else
warn("not an accessory")
end
end
end)
end)
Just add an attachment inside each Accessory’s Handle, and name it as the proper rig’s attachment, you can see all the attachments if you enable it in model properties
Its not working. Do I have to do anything special with attachments like position it?
Yup, the Handle and the attachment should be positioned according to the character rig, so it’ll be placed in the proper position.
Send a capture of your accessory, the handle and the attachment along with the dummy
Look, here I made a quick accessory, its just a neon part called Handle inside the accessory.
Inside the Handle theres an attachment called “BodyFrontAttachment”, the attachment is aligned with the rig’s attachment (look the arrow axis, orange and yellow), so it’ll be positioned at that attachment using that alignment.
This is when I join game:
Another thing to add. All the meshes inside your Accessory are welded to the Handle or not?
Should be welded, not anchored, massless, etc
Nevermind I got it working. Thanks!
Thats great, what was the problem? :v
Turns out it wasnt welded. there were 2 different copies so I got confused.
Yup, the things was looking not exactly welded xD
Great now is working, if any reply helped you mark it as solution :3
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.