I’m working on a script that prints out the amount of friends a specified user has. The issue is that it stops at 50 friends everytime, even if the player has more than 50 friends. Anyone know how to fix this?
local friendsArray = {}
local friendCount = 0
local success, page = pcall(function() return Players:GetFriendsAsync(targetUserId) end)
if success then
repeat
local info = page:GetCurrentPage()
for i, friendInfo in pairs(info) do
table.insert(friendsArray, friendInfo.Id)
end
if not page.IsFinished then
page:AdvanceToNextPageAsync()
end
task.wait()
until page.IsFinished
else
print("Failed to get friends")
end
for _, friend in friendsArray do
friendCount += 1
task.wait()
end
print(friendCount)