local http = game:GetService("HttpService") --Variable that holds a reference to the HTTP service.
local id = 261 --This is the ID of the user. This can be found in the player under the UserId property.

local friends = http:GetAsync("https://api.rprxy.xyz/users/" .. id .. "/friends",true) --We can use concatenation to add the id variable into the link. The true value is to make sure that old results aren't used if we've already requested from the link before (AKA caching).
friends = http:JSONDecode(friends) --Decode the JSON array that's returned from the request so the script can read it.

for i = 1,#friends do --Run this loop depending on how many entries there are in the table.
    print(friends[i]["Username"]) --Prints each username into the console.
end

How would i properly get it to display the friends usernames and userIDs? What my ultimate goal is to get the usernames of all a user's friends, and then those friend's friends. I only want the userID so that it can fetch the usernames for the friends it originally got.

5 comments

0

properly format your code by highlighting it and clicking the Lua logo

1

I put the code in a code block; please in the future do that. https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site

0
0

my bbay editing questions u sxy little community moderator ;)

0

My train of thought was that I could just pull the userID of the friends of the userID, in this case 261, and use those userIds instead of a preset ID.