Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i access friends from a player?

So I want to make this thing where it will show if your friends are playing like the one in meep city But I couldn't find anything on youtube Can someone help me?

5 comments

0

this is ur solution ezpz

0

well i cant mark this question anwserd as that is a comment

0

ill post an answer

3 answers

if player:IsFriendsWith(playersuserid) then -- insert the userid of the player

1 comment

0

Ik btu i want a list of friends

Players:GetFriendsAsync returns a FriendPages that can be used to get the Player's friends. We need to make sure to pcall (protected call) the request, since it is requesting data from an external web server, which may be unsuccessful (in which case, the function will error):

local players = game:GetService("Players")

-- variant<FriendPages, nil> get_friends(Player player)
local function get_friends(player)
	assert(typeof(player) == "Instance" and player:IsA("Player"), "bad argument #1 to get_friends")
	
	local is_successful, friend_pages = pcall(players.GetFriendsAsync, players, player.UserId)
	if not is_successful then
		return nil
	end
	return friend_pages
end

This discussion is preserved as it was. New answers, comments, and votes are closed.