I can’t get any FRIEND information at all when I run the following code.
I have tried by running it on both ServerSide and ClientSide.
Id will be my UserId.
There is no particular Error, etc., and it returns empty.
The lua code output by roblox-ts is shown here.
function PlayersManager:createNpc()
print("createNpc")
local friendPages = Players:GetFriendsAsync(5154434305)
while not friendPages.IsFinished do
print("friendPages.IsFinished")
local friends = friendPages:GetCurrentPage()
for _, friend in friends do
local friendUserId = friend.Id
local friendName = friend.Username
print("friendUserId: " .. tostring(friendUserId) .. " friendName: " .. friendName)
end
friendPages:AdvanceToNextPageAsync()
end
end
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, ", "))```