Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i access friends from a player?

Asked by 5 years ago

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?

0
this is ur solution ezpz Gey4Jesus69 2705 — 5y
0
well i cant mark this question anwserd as that is a comment MahadTheIronSword 98 — 5y
0
ill post an answer Gey4Jesus69 2705 — 5y

3 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

GetFriendsOnline

Ad
Log in to vote
0
Answered by
Imperialy 149
5 years ago
if player:IsFriendsWith(playersuserid) then -- insert the userid of the player
0
Ik btu i want a list of friends MahadTheIronSword 98 — 5y
Log in to vote
0
Answered by
BenSBk 781 Moderation Voter
5 years ago

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

Answer this question