Simply the title. For some reason, when using GetFriendsAsync() on certain player’s UserIds, it returns the page finished (IsFinished = true) and the function that iterates through the pages is empty.
It works for some people, and others it does not. Is there a privacy setting that makes this not work?
Here is the function if needed to test. My UserId that works with this is 90537338, and one of my players’ UserId that it doesn’t work with is 1577294332.
local function GetFriends(Player: Player): {number}
local userId = Player.UserId
local friendPages = Players:GetFriendsAsync(userId)
local userIds = {}
while not friendPages.IsFinished do
local currentPage = friendPages:GetCurrentPage()
for _, Item in currentPage do
table.insert(userIds, Item.Id)
end
friendPages:AdvanceToNextPageAsync()
end
return userIds
end
Pages.IsFinished being true does not mean that there is no information, it just means that amount of information does not require more than one page. The user ID that you gave us has a friend count of 17, while your friend count is ~5x that amount. Your code does not account for this and it abandons the loop prematurely. Change your code to the following:
local function getUserIdsOfFriends(player: Player): {number}
local pages = Players:GetFriendsAsync(player.UserId)
local userIds = {}
while true do
for _, info in pages:GetCurrentPage() do
table.insert(userIds, info.Id)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
end
return userIds
end