# llGetObjectLinkKey

*LSL function*

```lsl
key key llGetObjectLinkKey(key object_id, integer link);
```

- `key object_id`: UUID of the target prim or linkset.
- `integer link`: Link number (1 for root, >1 for children) or a LINK_* flag of the prim to retrieve.

- Returns: `key`
- Energy: 10

Returns the key (UUID) of the linked child prim specified by link within the linkset identified by object_id.

```lsl title="How to use" frame="terminal"
key result = llGetObjectLinkKey(NULL_KEY, 0);
```

## Examples

<details open>
<summary>Drag this script on to linked and unlinked prims, with avatars sitting or not, to see how [llGetLinkKey](/functions/llGetLinkKey/) relates to [llGetKey](/functions/llGetKey/), [llGetLinkNumber](/functions/llGetLinkNumber/), [llGetNumberOfPrims](/functions/llGetNumberOfPrims/), [LINK_ROOT](/constants/LINK_ROOT/), etc.</summary>

```lsl
// Return the name of a link num else the empty string.
string getLinkNumName(integer link)
{
    if (LINK_THIS == link) return "LINK_THIS";
    if (LINK_ALL_CHILDREN == link) return "LINK_ALL_CHILDREN";
    if (LINK_ALL_OTHERS == link) return "LINK_ALL_OTHERS";
    if (LINK_SET == link) return "LINK_SET";
    if (LINK_ROOT == link) return "LINK_ROOT";
    return "";
}

// Say the key of each linked prim.
default
{
    state_entry()
    {
        integer theLink = llGetLinkNumber();

        key theLinkKey = llGetKey();
        key owner = llGetOwner();
        key creator = llGetCreator();

        // Visit each link num.

        integer link;
        integer primmed = llGetNumberOfPrims();
        for (link = -5; link <= (primmed + 5); ++link)
        {
            key linkKey = llGetLinkKey(link);

            // Detail the key at the link num.

            string line = (string) linkKey; // large constant width

            if (linkKey == owner) line += " llGetOwner";
            if (linkKey == creator) line += " llGetCreator";
            if (linkKey == theLinkKey) line += " llGetKey";

            // Detail the link num.

            line += " @ " + (string) link;
            line += " " + getLinkNumName(link);
            if (link == theLink) line += " llGetLinkNumber";
            if (link == primmed) line += " llGetNumberOfPrims";

            // Say the detail if fun.

            if (linkKey != NULL_KEY)
            {
                llOwnerSay(line);
            }
        }

        // Always count the linked prims.

        llOwnerSay((string) primmed + " llGetNumberOfPrims");
        llOwnerSay("OK");
    }
}
```

</details>

## Known issues

From the issue templates included by the wiki article:

- SVC-600 (bug): llGetLinkKey returns the wrong result when passed LINK_THIS

## Related functions

The original wiki page documents these functions together with this one:

- [llGetLinkKey](/functions/llGetLinkKey/)

## See also

### Functions

- [llGetKey](/functions/llGetKey/)
- [llGetLinkName](/functions/llGetLinkName/)

---

*Source: [LlGetLinkKey](https://wiki.secondlife.com/wiki/LlGetLinkKey) on the Second Life Wiki. Content from the Second Life Wiki articles LlGetLinkKey (revision 1212153, 2022-09-19), Template:Issues/SVC-600 (revision 1153096, 2011-09-05) and Template:LSL Function/link (revision 1216622, 2024-05-04), CC BY-SA 3.0.*

---

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