Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

New to scripting, how would I get the friends ID in this script?

Asked by 5 years ago
Edited by TheeDeathCaster 5 years ago
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.

0
properly format your code by highlighting it and clicking the Lua logo DeceptiveCaster 3761 — 5y
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 TheeDeathCaster 2368 — 5y
0
you can only get the current users friends https://developer.roblox.com/api-reference/function/Player/GetFriendsOnline User#5423 17 — 5y
0
my bbay editing questions u sxy little community moderator ;) User#24403 69 — 5y
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. ravioli_formioli 0 — 5y

Answer this question