Hey! So, i am currently working on a game where i’ll be in need off getting every friend a player has. In order to do that, i would need to use the :GetFriendsAsync function. Although it works and gets some off my friends, it only gets 50 off them. I have 78 friends on roblox, how would i make it get all of them?
This is my code.
game.ReplicatedStorage.StartFriends.OnServerEvent:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
Player:FindFirstChild("InMenu").Value = false
local players = game:GetService("Players")
local PlayerUI = game.ServerStorage.PlayerUI.MainPlayer:Clone()
if Player.UserId == game.CreatorId then
PlayerUI.Frame.Developer.Visible = true
else
PlayerUI.Frame.Developer.Visible = false
end
PlayerUI.Adornee = Character:WaitForChild("Head")
PlayerUI.Parent = Character
PlayerUI.MaxDistance = 50
local friendsId = Player.UserId
local PlayersFriends = {}
local Click = script.Click:Clone()
Click.Parent = Character:FindFirstChild("Head")
local success, page = pcall(function() return players:GetFriendsAsync(friendsId) end)
if success then
repeat
local info = page:GetCurrentPage()
for i, friendInfo in pairs(info) do
table.insert(PlayersFriends, friendInfo)
end
if not page.IsFinished then
page:AdvanceToNextPageAsync()
print("advanced")
end
until page.IsFinished
end
while true do
wait(1)
if not Character then break end
if Character:WaitForChild("Humanoid").Health <= 0 then break end
local leaderstats = Player:WaitForChild("leaderstats")
for i,v in pairs(PlayersFriends) do
if not Character then break end
if Character:WaitForChild("Humanoid").Health <= 0 then break end
if Player:WaitForChild("CanSeeFriends").Value == true then
leaderstats:FindFirstChild("Friends").Value = #PlayersFriends
PlayerUI.Frame.Friends.Text = "Friends With: "..v.Username
if Character:FindFirstChild("Head"):FindFirstChild("Click") then
Character:FindFirstChild("Head"):FindFirstChild("Click"):Play()
end
wait(1)
print("changed")
else
leaderstats:FindFirstChild("Friends").Value = 0
PlayerUI.Frame.Friends.Text = "[HIDDEN]"
end
end
end
end)