Skip to content
lsl.devlsl.devLSL Dev

llAttachToAvatar

function
Function syntax
llAttachToAvatar(
  1. integer attach_point// ATTACH_* constant or integer value representing the target attachment point. Values: AttachPoint
);
Energy
10

Attaches the object to the avatar who has granted permission to the script. The object is taken into the users inventory and attached to attach_point.

If attach_point is zero, then the object attaches to the attach point it was most recently attached to.

How to use
llAttachToAvatar(0);

Body

Constant#NameComment
ATTACH_HEAD2Skullhead
ATTACH_NOSE17Nosenose
ATTACH_MOUTH11Mouthmouth
ATTACH_FACE_TONGUE52Tonguetongue
ATTACH_CHIN12Chinchin
ATTACH_FACE_JAW47Jawjaw
ATTACH_LEAR13Left Earleft ear
ATTACH_REAR14Right Earright ear
ATTACH_FACE_LEAR48Alt Left Earleft ear (extended)
ATTACH_FACE_REAR49Alt Right Earright ear (extended)
ATTACH_LEYE15Left Eyeleft eye
ATTACH_REYE16Right Eyeright eye
ATTACH_FACE_LEYE50Alt Left Eyeleft eye (extended)
ATTACH_FACE_REYE51Alt Right Eyeright eye (extended)
ATTACH_NECK39Neckneck
ATTACH_LSHOULDER3Left Shoulderleft shoulder
ATTACH_RSHOULDER4Right Shoulderright shoulder
ATTACH_LUARM20L Upper Armleft upper arm
ATTACH_RUARM18R Upper Armright upper arm
ATTACH_LLARM21L Lower Armleft lower arm
ATTACH_RLARM19R Lower Armright lower arm
ATTACH_LHAND5Left Handleft hand
ATTACH_RHAND6Right Handright hand
ATTACH_LHAND_RING141Left Ring Fingerleft ring finger
ATTACH_RHAND_RING142Right Ring Fingerright ring finger
ATTACH_LWING45Left Wingleft wing
ATTACH_RWING46Right Wingright wing
ATTACH_CHEST1Chestchest/sternum
ATTACH_LEFT_PEC29Left Pecleft pectoral
ATTACH_RIGHT_PEC30Right Pecright pectoral
ATTACH_BELLY28Stomachbelly/stomach/tummy
ATTACH_BACK9Spineback
ATTACH_TAIL_BASE43Tail Basetail base
ATTACH_TAIL_TIP44Tail Tiptail tip
ATTACH_AVATAR_CENTER40Avatar Centeravatar center/root
ATTACH_PELVIS10Pelvispelvis
ATTACH_GROIN53Groingroin
ATTACH_LHIP25Left Hipleft hip
ATTACH_RHIP22Right Hipright hip
ATTACH_LULEG26L Upper Legleft upper leg
ATTACH_RULEG23R Upper Legright upper leg
ATTACH_RLLEG24R Lower Legright lower leg
ATTACH_LLLEG27L Lower Legleft lower leg
ATTACH_LFOOT7Left Footleft foot
ATTACH_RFOOT8Right Footright foot
ATTACH_HIND_LFOOT54Left Hind Footleft hind foot
ATTACH_HIND_RFOOT55Right Hind Footright hind foot
HUD
ConstantComment
ATTACH_HUD_CENTER_231HUD Center 2
ATTACH_HUD_TOP_RIGHT32HUD Top Right
ATTACH_HUD_TOP_CENTER33HUD Top
ATTACH_HUD_TOP_LEFT34HUD Top Left
ATTACH_HUD_CENTER_135HUD Center
ATTACH_HUD_BOTTOM_LEFT36HUD Bottom Left
ATTACH_HUD_BOTTOM37HUD Bottom
ATTACH_HUD_BOTTOM_RIGHT38HUD Bottom Right
Special
ConstantComment
ATTACH_ANY_HUD-1A special constant representing all HUD attachment points when filtering.
  • Attach points can be occupied by multiple attachments.1
    • This was not always the case, previously if attach_point was occupied, the existing object was detached and the new attachment took it’s place.
  • Objects attached to the head (and any attachment position within the head) will not be visible in First Person view (aka Mouselook) if “show attachments in mouselook” is disable.
  • If attach_point is zero but the object was never previously attached, it defaults to the right hand (ATTACH_RHAND).
  • If the object is already attached the function fails silently, regardless if the attach_point is a different attach point. — SCR-137
Example 1
11 collapsed lines
//-- rez object on ground, drop in this script, it will request permissions to attach,
//-- and then attach to the left hand if permission is granted. if permission is denied,
//-- then the script complains.
default
{
state_entry()
{
llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
}
run_time_permissions( integer vBitPermissions )
{
if ( vBitPermissions & PERMISSION_ATTACH )
llAttachToAvatar( ATTACH_LHAND );
else
llOwnerSay( "Permission to attach denied" );
17 collapsed lines
}
on_rez(integer rez)
{
if (!llGetAttached() ) //reset the script if it's not attached.
llResetScript();
}
attach(key id)
{
// The attach event is called on both attach and detach, but 'id' is only valid on attach
if (id)
llOwnerSay( "The object is attached to " + llKey2Name(id) );
else
llOwnerSay( "The object is not attached");
}
}

From the issue templates included by the wiki article:

  • VWR-12525 (bug): llAttachToAvatar() can cause parentless attachments that can subsequently crash the client when selected
  • SCR-137 (nf): Allow llAttachToAvatar() to switch attachment locations
  • SVC-890 (bug): llAttachToAvatar can cause a stack/heap collision in certain circumstances
  • SCR-277 (nf): Add companion command to llAttachToAvatar() to allow attaching multiple items in same attachment point
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.

  1. Multiple attachments per attach point were added as result of SCR-277 ↩