PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

AddAccessory

A humanoid with an accessory that was attached using AddAccessory

AddAccessory is a function that attaches the specified Accessory to the Humanoid.

How are Accessories attached to Humanoids?

Attachments that share the same name, and thus are used to connect the accessory.

The Accessory is parented to the Humanoid|Humanoid's parent and then attached.

An Accessory is attached to the character by searching for an Attachment in the Humanoid|Humanoid's parent that shares the same name as an Attachment in the accessory’s Handle Part. If one is found, the Handle part will be connected to the parent of the Attachment using a Weld. This weld will be configured so the Attachment|Attachments occupy the same space.

If the required Attachment can not be found, then the Accessory will remain parented to the Humanoid|Humanoid's parent but it will be unattached.

Parameters

Name Type Default Description

The Accessory to be attached

Returns

Return Type Summary

Code Samples


[Humanoid] AddAccessory Example

This script generates the “Clockwork’s Shades” Accessory from scratch, and then attaches it to the player’s character using Humanoid.AddAccessory You should paste this code into a regular script, and then parent it inside of the StarterPlayer's StarterCharacterScripts folder.

local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")

-- Create the Accessory.
local clockworksShades = Instance.new("Accessory")
clockworksShades.Name = "ClockworksShades"

local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1,1.6,1)
handle.Parent = clockworksShades

local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "FaceFrontAttachment"
faceFrontAttachment.Position = Vector3.new(0,-0.24,-0.45)
faceFrontAttachment.Parent = handle

local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(1,1.3,1)
mesh.MeshId = "rbxassetid://1577360"
mesh.TextureId = "rbxassetid://1577349"
mesh.Parent = handle

-- Attach the Accessory to the humanoid.
humanoid:AddAccessory(clockworksShades)