Detaches the scripted object from the avatar it’s attached to. Requires PERMISSION_ATTACH (via llRequestPermissions).
After detaching, the attach() event hander is called with the value NULL_KEY.
Calling this function from a child-prim will fail silently.
Clicking on an object in-world that calls llAttachToAvatar moves that object into your inventory (also highlights it and labels it ‘worn’). You can see it there as soon as it’s attached. Calling this function will leave the item in your inventory. This can make for a novel version of ‘take’ that only relies on the left mouse button and provides a confirmation dialog via the permissions request.
A: Not directly. llDie is the function used to delete objects, but it doesn’t work on attachments.
Instead of simply calling llDetachFromAvatar on its own, your best option is to switch states to a “dead” state — one where the attach() event handler calls llDetachFromAvatar, causing the attachment to automatically detach, (with PERMISSION_ATTACH granted, of course) and where on_rez() contains llDie. This will cause the object to be deleted, should it be rezzed on the ground. You can also stick llSetObjectName in the “dead” state’s state_entry(). This would rename it to something like “Expired Attachment – Delete Me”, indicating to the inventory’s owner that they’re free to get rid of it.