# llAttachToAvatarTemp

*LSL function*

```lsl
void llAttachToAvatarTemp(integer attach_point);
```

- `integer attach_point`: ATTACH_* constant or integer value representing the target attachment point.

- Energy: 10
- Permission: `PERMISSION_ATTACH`

Follows the same convention as [llAttachToAvatar](/functions/llAttachToAvatar/), with the exception that the object will not create new inventory for the user, and will disappear on detach or disconnect. Also, this function can be used on avatars other than the owner (if granted permission) in which case the ownership is changed to the new wearer.

It should be noted that when an object is attached temporarily, a user cannot 'take' or 'drop' the object that is attached to them.

The user does not have to be the owner of the object in advance; this function transfers ownership automatically (the usual permissions required to transfer objects apply).

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

```lsl title="How to use" frame="terminal"
llAttachToAvatarTemp(0);
```

## Specification

:::note
Constants in *italic* require a viewer compatible with the [Project Bento](https://wiki.secondlife.com/wiki/Project_Bento_Skeleton_Guide) skeleton.
:::

<table>
	<tr>
		<td>

			****Body****

			| Constant | # | Name | Comment |
			| --- | --- | --- | --- |
			| [ATTACH_HEAD](/constants/ATTACH_HEAD/) | 2 | Skull | head |
			| [ATTACH_NOSE](/constants/ATTACH_NOSE/) | 17 | Nose | nose |
			| [ATTACH_MOUTH](/constants/ATTACH_MOUTH/) | 11 | Mouth | mouth |
			| [*ATTACH_FACE_TONGUE*](/constants/ATTACH_FACE_TONGUE/) | 52 | Tongue | tongue |
			| [ATTACH_CHIN](/constants/ATTACH_CHIN/) | 12 | Chin | chin |
			| [*ATTACH_FACE_JAW*](/constants/ATTACH_FACE_JAW/) | 47 | Jaw | jaw |
			| [ATTACH_LEAR](/constants/ATTACH_LEAR/) | 13 | Left Ear | left ear |
			| [ATTACH_REAR](/constants/ATTACH_REAR/) | 14 | Right Ear | right ear |
			| [*ATTACH_FACE_LEAR*](/constants/ATTACH_FACE_LEAR/) | 48 | Alt Left Ear | left ear (extended) |
			| [*ATTACH_FACE_REAR*](/constants/ATTACH_FACE_REAR/) | 49 | Alt Right Ear | right ear (extended) |
			| [ATTACH_LEYE](/constants/ATTACH_LEYE/) | 15 | Left Eye | left eye |
			| [ATTACH_REYE](/constants/ATTACH_REYE/) | 16 | Right Eye | right eye |
			| [*ATTACH_FACE_LEYE*](/constants/ATTACH_FACE_LEYE/) | 50 | Alt Left Eye | left eye (extended) |
			| [*ATTACH_FACE_REYE*](/constants/ATTACH_FACE_REYE/) | 51 | Alt Right Eye | right eye (extended) |
			| [ATTACH_NECK](/constants/ATTACH_NECK/) | 39 | Neck | neck |
			| [ATTACH_LSHOULDER](/constants/ATTACH_LSHOULDER/) | 3 | Left Shoulder | left shoulder |
			| [ATTACH_RSHOULDER](/constants/ATTACH_RSHOULDER/) | 4 | Right Shoulder | right shoulder |
			| [ATTACH_LUARM](/constants/ATTACH_LUARM/) | 20 | L Upper Arm | left upper arm |
			| [ATTACH_RUARM](/constants/ATTACH_RUARM/) | 18 | R Upper Arm | right upper arm |
			| [ATTACH_LLARM](/constants/ATTACH_LLARM/) | 21 | L Lower Arm | left lower arm |
			| [ATTACH_RLARM](/constants/ATTACH_RLARM/) | 19 | R Lower Arm | right lower arm |
			| [ATTACH_LHAND](/constants/ATTACH_LHAND/) | 5 | Left Hand | left hand |
			| [ATTACH_RHAND](/constants/ATTACH_RHAND/) | 6 | Right Hand | right hand |
			| [*ATTACH_LHAND_RING1*](/constants/ATTACH_LHAND_RING1/) | 41 | Left Ring Finger | left ring finger |
			| [*ATTACH_RHAND_RING1*](/constants/ATTACH_RHAND_RING1/) | 42 | Right Ring Finger | right ring finger |
			| [*ATTACH_LWING*](/constants/ATTACH_LWING/) | 45 | Left Wing | left wing |
			| [*ATTACH_RWING*](/constants/ATTACH_RWING/) | 46 | Right Wing | right wing |
			| [ATTACH_CHEST](/constants/ATTACH_CHEST/) | 1 | Chest | chest/sternum |
			| [ATTACH_LEFT_PEC](/constants/ATTACH_LEFT_PEC/) | 29 | Left Pec | left pectoral |
			| [ATTACH_RIGHT_PEC](/constants/ATTACH_RIGHT_PEC/) | 30 | Right Pec | right pectoral |
			| [ATTACH_BELLY](/constants/ATTACH_BELLY/) | 28 | Stomach | belly/stomach/tummy |
			| [ATTACH_BACK](/constants/ATTACH_BACK/) | 9 | Spine | back |
			| [*ATTACH_TAIL_BASE*](/constants/ATTACH_TAIL_BASE/) | 43 | Tail Base | tail base |
			| [*ATTACH_TAIL_TIP*](/constants/ATTACH_TAIL_TIP/) | 44 | Tail Tip | tail tip |
			| [ATTACH_AVATAR_CENTER](/constants/ATTACH_AVATAR_CENTER/) | 40 | Avatar Center | avatar center/root |
			| [ATTACH_PELVIS](/constants/ATTACH_PELVIS/) | 10 | Pelvis | pelvis |
			| [*ATTACH_GROIN*](/constants/ATTACH_GROIN/) | 53 | Groin | groin |
			| [ATTACH_LHIP](/constants/ATTACH_LHIP/) | 25 | Left Hip | left hip |
			| [ATTACH_RHIP](/constants/ATTACH_RHIP/) | 22 | Right Hip | right hip |
			| [ATTACH_LULEG](/constants/ATTACH_LULEG/) | 26 | L Upper Leg | left upper leg |
			| [ATTACH_RULEG](/constants/ATTACH_RULEG/) | 23 | R Upper Leg | right upper leg |
			| [ATTACH_RLLEG](/constants/ATTACH_RLLEG/) | 24 | R Lower Leg | right lower leg |
			| [ATTACH_LLLEG](/constants/ATTACH_LLLEG/) | 27 | L Lower Leg | left lower leg |
			| [ATTACH_LFOOT](/constants/ATTACH_LFOOT/) | 7 | Left Foot | left foot |
			| [ATTACH_RFOOT](/constants/ATTACH_RFOOT/) | 8 | Right Foot | right foot |
			| [*ATTACH_HIND_LFOOT*](/constants/ATTACH_HIND_LFOOT/) | 54 | Left Hind Foot | left hind foot |
			| [*ATTACH_HIND_RFOOT*](/constants/ATTACH_HIND_RFOOT/) | 55 | Right Hind Foot | right hind foot |

		</td>
		<td></td>
		<td>

			<table>
				<caption>**HUD**</caption>
				<tr>
					<th colspan="2">Constant</th>
					<th>Comment</th>
				</tr>
				<tr>
					<td>[ATTACH_HUD_CENTER_2](/constants/ATTACH_HUD_CENTER_2/)</td>
					<td>31</td>
					<td>HUD Center 2</td>
				</tr>
				<tr>
					<td>[ATTACH_HUD_TOP_RIGHT](/constants/ATTACH_HUD_TOP_RIGHT/)</td>
					<td>32</td>
					<td>HUD Top Right</td>
				</tr>
				<tr>
					<td>[ATTACH_HUD_TOP_CENTER](/constants/ATTACH_HUD_TOP_CENTER/)</td>
					<td>33</td>
					<td>HUD Top</td>
				</tr>
				<tr>
					<td>[ATTACH_HUD_TOP_LEFT](/constants/ATTACH_HUD_TOP_LEFT/)</td>
					<td>34</td>
					<td>HUD Top Left</td>
				</tr>
				<tr>
					<td>[ATTACH_HUD_CENTER_1](/constants/ATTACH_HUD_CENTER_1/)</td>
					<td>35</td>
					<td>HUD Center</td>
				</tr>
				<tr>
					<td>[ATTACH_HUD_BOTTOM_LEFT](/constants/ATTACH_HUD_BOTTOM_LEFT/)</td>
					<td>36</td>
					<td>HUD Bottom Left</td>
				</tr>
				<tr>
					<td>[ATTACH_HUD_BOTTOM](/constants/ATTACH_HUD_BOTTOM/)</td>
					<td>37</td>
					<td>HUD Bottom</td>
				</tr>
				<tr>
					<td>[ATTACH_HUD_BOTTOM_RIGHT](/constants/ATTACH_HUD_BOTTOM_RIGHT/)</td>
					<td>38</td>
					<td>HUD Bottom Right</td>
				</tr>
			</table>

			<table>
				<caption>**Special**</caption>
				<tr>
					<th colspan="2">Constant</th>
					<th>Comment</th>
				</tr>
				<tr>
					<td>[ATTACH_ANY_HUD](/constants/ATTACH_ANY_HUD/)</td>
					<td>-1</td>
					<td>A special constant representing all HUD attachment points when filtering.</td>
				</tr>
			</table>

		</td>
	</tr>
</table>

## Caveats

- When object ownership changes, any granted permissions are reset. After a successful attach, you will need a fresh call to [llRequestPermissions](/functions/llRequestPermissions/) to allow [llDetachFromAvatar](/functions/llDetachFromAvatar/) and other permission-required functions to work.
  - Until successful attachment via this method, previously granted permissions are retained as normal.
- The attach step is not guaranteed to succeed, and this function should not be relied on as a security measure. Use the same permission and script precautions you would use with conventional inventory transfers.
- If you use [llAttachToAvatarTemp](/functions/llAttachToAvatarTemp/) in an object that you do not have permission to transfer, the function will fail with a script error *No permission to transfer*, even if you are trying to attach it to yourself.
- Temporary attachments cannot request the permission [PERMISSION_TELEPORT](/constants/PERMISSION_TELEPORT/), the following error will be returned: *"Temporary attachments cannot request runtime permissions to teleport"*
- Attach points can be occupied by multiple attachments.[^wiki-b6e0ca]
  - 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](https://wiki.secondlife.com/wiki/Mouselook)) if "show attachments in mouselook" is disabled.
- If **attach_point** is zero but the object was never previously attached, it defaults to the right hand ([ATTACH_RHAND](/constants/ATTACH_RHAND/)).
- If the object is already attached the function fails silently, regardless of the **attach_point** being a different [attach point](https://wiki.secondlife.com/wiki/Category:LSL_Integer/attach_point).
- If attached via a Land Scope [Experience](https://wiki.secondlife.com/wiki/Category:Experience_Tools) script, the object will be force-detached by the server if the owner enters a parcel that does not have the Experience allowed.
- If the target agent is already wearing the maximum number of attachments, the object will remain on the ground with the target agent as owner. Scripters may wish to do one or more workarounds:
  - check for successful attachment and [llDie](/functions/llDie/)() after a timeout or if the object is manipulated while unattached
  - check [llGetObjectDetails](/functions/llGetObjectDetails/)(avatarKey, \[[OBJECT_ATTACHED_SLOTS_AVAILABLE](/constants/OBJECT_ATTACHED_SLOTS_AVAILABLE/)\]) beforehand, and avoid attaching if zero slots available

[^wiki-b6e0ca]: Multiple attachments per attach point were added as result of [SCR-277](https://jira.secondlife.com/browse/SCR-277)

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={1-12, 18-43}
//-- 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 )
        {
            llAttachToAvatarTemp( ATTACH_LHAND );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }

    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }

    attach(key AvatarKey)
    {
        if(AvatarKey)
        {//event is called on both attach and detach, but Key is only valid on attach
            integer test = llGetAttached();
            if (test) {
                llOwnerSay( "The object is attached" );
            } else {
                llOwnerSay( "The object is not attached");
            }
        }
    }
}
```

</details>

<details>
<summary>Example 2</summary>

```lsl collapse={4-12, 18-30}
//-- This example can demonstrate ownership transfer of an object on a temporary basis using llAttachToAvatarTemp()
//-- Whoever touches will be asked for permission to attach, and upon granting permission will have the item attach,
//-- But not appear in Inventory.
default
{
    touch_start(integer num_touches)
    {
        llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH );
    }

    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_LHAND );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }

    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
}
```

</details>

<details>
<summary>Example 3</summary>

```lsl collapse={4-37, 43-51}
// This example illustrates how to handle permissions before and after llAttachToAvatarTemp has been called. Because ownership
// changes when the object is attached, the initial PERMISSION_ATTACH is revoked, and new permissions need to be requested.

integer gAttach = TRUE;

default
{

    touch_start(integer num)
    {
        if (gAttach)  // Object has not been attached yet
        {
            llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH);
            gAttach = FALSE;
        }
        else   // Object has been attached, but you still need PERMISSION_ATTACH in order to detach the object
        {
            if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH)
            {
                llDetachFromAvatar();  // Note that the object vanishes when detached, so there is no need to set gAttach = TRUE again
            }
        }
    }

    attach(key id)
    {
        if (id)  // Object has been attached, so request permissions again
        {
            llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
        }
    }

    run_time_permissions (integer perm)
    {
        if (!gAttach)  //First time
        {
            if (perm & PERMISSION_ATTACH)
            {
                gAttach = TRUE;
                llAttachToAvatarTemp(ATTACH_HEAD);  // Initial PERMISSION_ATTACH is revoked at this point
            }
        }
        else  // Second time
        {
            if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION)
            {
                llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            }
        }
    }
}
```

</details>

<details>
<summary>An alternative solution:</summary>

```lsl collapse={1-13}
// Because ownership changes when the object is attached, the initial PERMISSION_ATTACH is revoked, and new permissions need to be requested.

default
{
    touch_start(integer num)
    {
        if (!llGetAttached()) llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH);
        else if ( llGetPermissions() & PERMISSION_ATTACH) llDetachFromAvatar();
    }
    attach(key id)
    {
        if (id) llRequestPermissions( id, PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions (integer perm)
    {
        if (!llGetAttached() && (perm & PERMISSION_ATTACH)) llAttachToAvatarTemp( ATTACH_NOSE);
        if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0));
    }
}
```

</details>

## History

Date of Release [24/07/2012](https://wiki.secondlife.com/wiki/Release_Notes/Second_Life_Server/12#12-07-24-262437)

## Known issues

From the issue templates included by the wiki article:

- SCR-395 (bug): llAttachToAvatarTemp worn objects do not keep group name.

## See also

### Functions

- [llDetachFromAvatar](/functions/llDetachFromAvatar/) — Detaches the object from the avatar
- [llGetAttached](/functions/llGetAttached/) — Gets the attach point number

---

*Source: [LlAttachToAvatarTemp](https://wiki.secondlife.com/wiki/LlAttachToAvatarTemp) on the Second Life Wiki. Content from the Second Life Wiki articles LlAttachToAvatarTemp (revision 1216156, 2024-01-28), Template:LSL Constants Attachment (revision 1217598, 2024-11-06), Template:Issues/SCR-395 (revision 1184879, 2013-12-07) and Template:LSL Function/permission (revision 1200093, 2016-05-12), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llAttachToAvatarTemp/
