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

local Players = game:GetService("Players")
local USERNAME = "Cozecant"
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
print("Friends of " .. USERNAME .. ": " .. table.concat(usernames, ", "))

Summary

Properties

Methods

Events

Properties

Methods

Events