I can't seem to do it

I thought I could learn how to use “GetFriendsAsync” But I couldn’t seem to do it.
Do you know how I would start the script of?

Go check out Players:GetFriendsASync

To start of get the userid of the player:

local uid = game:GetService("Players").LocalPlayer.UserID

Then use the getfriendsasync

game:GetService("Players"):GetFriendsASync(uid)

it would return as FriendPages

1 Like

Should be UserId not UserID even if properties are case insensitive.

local Game = game
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Success, Result = pcall(Players.GetFriendsAsync, Players, Player.UserId)
if Success then --Check if API method returned a 'FriendPages' object.
	while true do
		local Page = Result:GetCurrentPage() --Get the 'FriendPages' object's current page.
		for _, Item in ipairs(Page) do --Iterate over the page's items.
			for Key, Value in pairs(Item) do --Iterate over each item's contents.
				print(Key, Value) --Output the contents.
			end
		end
		
		if Result.IsFinished then --Check if the end of the 'FriendPages' object has been reached.
			break --Break the loop.
		else
			Result:AdvanceToNextPageAsync() --Advance to the next page of the 'FriendPages' object.
		end
	end
else
	warn(Result)
end
1 Like