friends.find users[i] returns nil

Hello!

I am trying to set up multiplayer using Corona Cloud and integrating it has been pretty smooth so far. I am now at the point where the player can type in a name, the game finds it, and sends them a game request. It is not working out.

I am using the friendListener from the docs and I cannot seem to get it to work.

http://docs.coronalabs.com/guide/cloud/multiplayer/index.html

I can add a keyword, find the user, print “users” (event.response), but trying to get any data from it fails.

if ( users[i].username == searchQuery ) then

This returns the error, “attempt to index field ‘?’ (a nil value)” I tried all the different tags (id, name, etc.) and they all are nil. Am I missing something obvious? Assistance would be greatly appreciated.  :slight_smile:

Wow, after 3 hours of battling with this, I find the answer right after making a post. I looked around my code for other event.responses and found a json.decode() around one. I threw it on and now it works.

local users = json.decode(event.response)

Hopefully this helps someone out there.

Wow, after 3 hours of battling with this, I find the answer right after making a post. I looked around my code for other event.responses and found a json.decode() around one. I threw it on and now it works.

local users = json.decode(event.response)

Hopefully this helps someone out there.