llGiveMoney(key destination, integer amount)

Transfers amount of Linden dollars from the script owner to destination. Requires the PERMISSION_DEBIT run-time permission.

destination can only be an avatar, not an object or a group. The recipient does not need to be in the same sim as the object. If amount is less than or equal to zero, the object will say “Invalid parameter in llGiveMoney().” This looks pretty unprofessional, so if you’re writing a vendor script that gives change (for example), you’ll probably want to avoid it.

Older versions of the LSL documentation stated that llGiveMoney returned an integer. If the owner has insufficient funds to cover the llGiveMoney call, an error will appear on the user’s screen (There is no longer an error message, the function silently fails.), but there will be no data returned to the script itself. The return integer from llGiveMoney is always zero.

As of Tuesday, November 6th, 2007, llGiveMoney is now throttled:
Use is limited to 30 payments in a 30 second interval for each resident on a region. Sustained overage will produce a script error and halt payments while the rate remains excessive. Historically, faster payments have failed intermittently.

This example script asks for the PERMISSION_DEBIT permission on startup and then tries to give L$1 to anyone who touches it.

default
{
     state_entry()
     {
          llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
     }

     touch_start(integer num_detected)
     {
          llGiveMoney(llDetectedKey(0),1);
     }
}

Another Example:

// ExampleMoney
// Pay the object money, this script refunds incorrect payments
// This code is public domain.

integer gCorrectAmount = 10; // this defines the correct price -- we only accept L$10

default
{
    state_entry()
    {
        // get permission from the owner to pay out money using the llGiveMoney function.
        llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
    }
     
    money(key id, integer amount)
    {
        // has the user paid the correct amount?
        if (amount == gCorrectAmount)
        {
            // if so, thank the payer by name.
            llSay(0,"Thank you, " + llKey2Name(id) + ".");
        }
        
        // is the amount paid less than it needs to be?
        else if (amount < gCorrectAmount)
        {
            // if so, tell them they're getting a refund, then refund their money.
            llSay(0,"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)amount + ".");
            llGiveMoney(id, amount); // refund amount paid.
        }
        
        // if it's not exactly the amount required, and it's not less than the amount required,
        // the payer has paid too much.
        else
        {
            // tell them they've overpaid.
            integer refund = amount - gCorrectAmount; // determine how much extra they've paid.
            llSay(0,"You paid too much, " + llKey2Name(id) + ". Your change is L$" + (string)refund + ".");
            llGiveMoney(id, refund); // refund their change.
        }
    }
}

Q: What happens if the owner doesn’t have enough funds to satisfy the llGiveMoney request?

A: The script pops up an error dialog stating “Insufficient funds” (There is no longer an error message, the function silently fails.). Because there isn’t any return value from llGiveMoney, you need to keep track of money inside your script. This can be difficult to accomplish. There’s no direct way to get your script to know whether or not it’s out of money, but it’ll keep telling the owner that it’s out.
As KellyLinden explains: “It is not possible for llGiveMoney to return a meaningful value, the data is simply not available when and where it would be needed to make that happen.”

Q: Wait, it returns zero? Are you sure it doesn’t actually return nothing? Maybe you’re doing it wrong.

A: Nope, it definitely returns zero, and it does so every time.

When llGiveMoney fails due to “Insufficient Funds”, the script is not delayed: The error appears to the owner and no one else, and the script continues to function without any delay or conflict.

To receive money, use the money event.