I’m trying to pull the local player’s friends using the :GetFriendsAsync() function and then load their characters, but whenever I iterate through the page numbers I get the error shown in the title.
Here is my script
local Players = game:GetService("Players")
local function iteratePageNumbers(Pages)
coroutine.wrap(function()
local pagenum = 1
while task.wait() do
for _, item in ipairs(Pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if Pages.IsFinished then
break
end
Pages:AdvanceToNextAsync()
pagenum += 1
end
end)
end
local player = Players.LocalPlayer
local userId = player.UserId
local friendPages = Players:GetFriendsAsync(userId)
print(friendPages)
local friendsUsers = {}
--error right here
for item, pgNum in iteratePageNumbers(friendPages) do
table.insert(friendsUsers, item.Username)
end
print("Friends of " .. player.Name .. ": " .. table.concat(friendPages, ","))
This is basically the same script used in this documentation Players | Documentation - Roblox Creator Hub, but instead of getting the friends from a given user, I’m trying to get the friends from the local players and I’m getting an error. It could be a simple error but idk