PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetFriendsOnline

The GetFriendsOnline Player function returns a Articles/Table#dictionaries of online friends, specified by maxFriends.

The Array’s Content

Some fields are only present for certain location types. For example, PlaceId won’t be present when the location type is (mobile) website.

Name Type Description
VisitorId number The Player/UserId of the friend.
UserName string The user name of the friend.
LastOnline string When the user was last online.
IsOnline boolean If the friend is currently online.
LastLocation string The name of the friends current location.
PlaceId number The placeId of the friends last location.
GameId string The DataModel/JobId of the friends last location.
LocationType number The location type of the friends last location. 0 for mobile website. 1 for mobile in game. 2 for website. 3 for studio. 4 for ingame.

Parameters

Name Type Default Description
int
200

The maximum number of online friends to return. The default is 200.

Returns

Return Type Summary

An dictionary of online friends (see the table in the description to see what each the format of an entry).


Code Samples


How to Get a List of Online Friends

This example demonstrates how to get a dictionary of a player’s online friends.

It will returns at max as many friends as specified in the argument, which we set to 10. If the argument is blank, the default max number of friends to return is 200.

The example then prints the names of all online friends.

local player = game.Players.LocalPlayer

local dict = player:GetFriendsOnline(10)

for i,friend in pairs(dict) do
	print(friend.UserName)
end