學習
引擎類別
FriendPages
無法建立
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡。


概要

繼承成員
範例程式碼
列印 Roblox 朋友
local Players = game:GetService("Players")
local USERNAME = "Cozecant"
-- 首先,獲取玩家的用戶 ID
local userId = Players:GetUserIdFromNameAsync(USERNAME)
-- 然後,為他們的朋友獲取一個 FriendPages 對象
local friendPages = Players:GetFriendsAsync(userId)
-- 遍歷頁面,收集每個朋友的用戶名。每個頁面條目是
-- 一個包含朋友信息的表,包括用戶名。
local usernames = {}
while true do
for _, friend in ipairs(friendPages:GetCurrentPage()) do
table.insert(usernames, friend.Username)
end
if friendPages.IsFinished then
break
end
friendPages:AdvanceToNextPageAsync()
end
print("朋友的 " .. USERNAME .. ": " .. table.concat(usernames, ", "))
©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。