How do I get the player's friend

My goal is get the player’s friends and show it in a SurfaceGui

I also tried using GetFriendsAsync but I don’t understand
I even tried using the example code in the GetFriendsAsync

but instead get an error:
Expected ‘)’ (to close ‘(’ at column 6), got ‘table’

please help :frowning:

local Players = game:GetService("Players")

local USERNAME = "9c_Aw"

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, ", "))

image

there was missing concatenation

omg i didn’t know…
also thank you so much for helping me :smile: