This script was tested and works on OpenSim version 0.7.4!

To use this script, simply drop it into one of your attachments that you are wearing and the script should take care of all the rest. Happy smiling! The script is expandable to potentially include more smiles, however this version works with the built in animations "express_smile" and "express_toothsmile".

smile.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
integer o = -1;
 
default {
    state_entry() {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm) {
        if(perm & PERMISSION_TRIGGER_ANIMATION) {
            llSetTimerEvent(1);
        }
    }
    timer() {
        list smiles = [ "express_smile", "express_toothsmile" ];
        if(o = ~o) {
            llStartAnimation(llList2String(smiles, (integer)llFrand(2)));
            llSetTimerEvent(1.0);
            return;
        }
        integer i;
        for(i=0; i<llGetListLength(smiles); i++) {
            llStopAnimation(llList2String(smiles, i));
        }
        llSetTimerEvent(5+(integer)llFrand(10));
    }
    on_rez(integer num) {
        llResetScript();
    }
    changed(integer change) {
        llResetScript();
    }
}