key llAvatarOnSitTarget()

If an avatar is sitting on the sit target, this function will return the avatar’s key; NULL_KEY otherwise. This will only detect avatars sitting on sit targets defined with llSitTarget. At some point prior to SL 1.6.5, it would apparently work without, but has apparently not been the case for some time. Scripts compiled prior to the change will function correctly, but recompiling them will cause them to break.

Agents that sit on the object, are linked to the object and are added to the end of the link set. See llGetNumberOfPrims for example functions.


default {
    state_entry() {
        llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
        // Note that if both the vector and the rotation are zero,
        // the SitTarget is removed instead of set and the following will not work:
    changed(integer change) { // something changed
        if (change & CHANGED_LINK) { // and it was a link change
            llSleep(0.5); // llUnSit works better with this delay
            if (llAvatarOnSitTarget() != NULL_KEY) { // somebody is sitting on me
                llSay(0, "Get off!");
                llUnSit(llAvatarOnSitTarget()); // unsit him or her


Q: It’s only returning NULL_KEY! What’s up with that?
A: llAvatarOnSitTarget will only work if llSitTarget has been set.