FriendPages

Show Deprecated
Not Creatable
Not Replicated

FriendPages is a special version of the Pages returned by Players:GetFriendsAsync(). The items contained within describe information about a player's friends, and have the following structure:

NameTypeDescription
Idint64The user ID of the friend
UsernamestringThe current username of the friend
IsOnlinebooleanWhether or not the user is presently online.

See the code samples for an easy way to iterate over a player's friends.

Code Samples

Print Roblox Friends

1local Players = game:GetService("Players")
2
3local USERNAME = "Cozecant"
4
5local function iterPageItems(pages)
6 return coroutine.wrap(function()
7 local pagenum = 1
8 while true do
9 for _, item in ipairs(pages:GetCurrentPage()) do
10 coroutine.yield(item, pagenum)
11 end
12 if pages.IsFinished then
13 break
14 end
15 pages:AdvanceToNextPageAsync()
16 pagenum = pagenum + 1
17 end
18 end)
19end
20
21-- First, get the user ID of the player
22local userId = Players:GetUserIdFromNameAsync(USERNAME)
23-- Then, get a FriendPages object for their friends
24local friendPages = Players:GetFriendsAsync(userId)
25-- Iterate over the items in the pages. For FriendPages, these
26-- are tables of information about the friend, including Username.
27-- Collect each username in a table
28local usernames = {}
29for item, _pageNo in iterPageItems(friendPages) do
30 table.insert(usernames, item.Username)
31end
32
33print("Friends of " .. USERNAME .. ": " .. table.concat(usernames, ", "))

Summary

Properties

Events

Methods

Properties

Events

Methods