On Purchase

API -

function yourEvent(user, receiptData)
    --possible types are: avatar, color, action, gear, nametag
    log(user.displayName .. ' bought ' .. receiptData.name);
    
    --if the type is gear, color, or action, 
    --that means there will be a ":" in the item name -> block_man:blue
    
    --you can use 
    --local blah = helper.split(receiptData.name, ':'); 
    --then the item name will be. -> blah[2] -> blue
    
    log('type of item: ' .. receiptData.type);
    log('currency cost: ' .. receiptData.cost);
    log('platformCurrency cost: ' .. receiptData.platformCurrencyCost);
    log('was the item a gift? ' .. tostring(receiptData.gifted));
end

return function()
    addEvent('receipts', 'yourEvent'); --attaches the event to yourEvent()
    keepAlive();
end

Events are asynchronous coroutines.

Last updated