I want to achieve a way to get a specific player’s friends list. I don’t know if this is however possible at all, so please help me :))
3 Likes
Example by Roblox:
local Players = game:GetService("Players")
local USERNAME = "STOPEATCAK"
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum = pagenum + 1
end
end)
end
-- First, get the user ID of the player
local userId = Players:GetUserIdFromNameAsync(USERNAME)
-- Then, get a FriendPages object for their friends
local friendPages = Players:GetFriendsAsync(userId)
-- Iterate over the items in the pages. For FriendPages, these
-- are tables of information about the friend, including Username.
-- Collect each username in a table
local usernames = {}
for item, pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
end
-- and finally, print!
print("Friends of " .. USERNAME .. ": " .. table.concat(usernames, ", "))
https://developer.roblox.com/en-us/api-reference/class/FriendPages
9 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.