I'd suggest dumping the roll results to the log and inspecting them to verify your assumptions about the format: log(rollresults); It's hard to give you any suggestions without seeing more of your code. For example, I'm assuming this is in a sendChat() callback function, and I'm assuming you're sending something akin to '/roll SOME DICE EXPRESSION'. However, I can't really say without knowing those things. I can give you some javascript tips though: // verify that the property you want exists
if( rollresult && rollresult.rolls && rollresult.rolls.length ) {
for (var i = 0; i < rollresult.rolls.length; i++) {
// verify that the property you want exists
if(rollresult.rolls.results && rollresult.rolls.results.length) {
for (var i2 = 0; i2 < rollresult.rolls.results.length; i2++){
//stuff You can check to see if the property you want exists and avoid the crash by trying to reference a property on undefined by adding guards around your access. Javascript has the singular notion that the logical and (&&) instead of returning a boolean true or false returns the value that was considered true or false. This allows you to do all kinds of great things, but the practical upshot is that you can chain them together to keep checking deeper and deeper into an object. One point of vernacular. What you're dealing with is a Javascript Object. JSON is a text string encoding that represents a Javascript Object. The two terms are confusing initially, but it's important to keep the distinction separate. If you are doing the result of a /roll, you probably created your javascript object from a JSON string with JSON.parse().