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

How do I use GetFriendsOnline()?

Asked by
FOG20 5
9 years ago

How do I get the information from this table? http://wiki.roblox.com/index.php?title=API:Class/Player/GetFriendsOnline . I just want to be able to access the player's friend's VisitorId, Last Online, IsOnline, LastLocation, and PlaceId.

1 answer

Log in to vote
1
Answered by
legosweat 334 Moderation Voter
9 years ago

GetFriendsOnline() returns a array, or a table if you say of the player specified friends.

In this example, I'm just going to print out each online friend's VisitorId, PlaceId, and LocationType.

**LocalScript in StarterPlayerScripts: **

01local plr = game.Players.LocalPlayer
02 
03for i,v in pairs (plr:GetFriendsOnline()) do
04    print(" ") -- New Line (Making it look pretty in Output)
05    if v.VisitorId then
06    print("Friend #"..i, " id is "..v.VisitorId) -- Get their userId
07    end
08    if v.PlaceId then
09    print(" Last Place Visited Was: "..v.PlaceId) -- Get the place id of the game they're playing.
10    end
11    if v.LocationType == 0 then -- Checking location type
12        print(" Is on mobile website")
13    elseif v.LocationType == 1 then
14        print(" Is in mobile game")
15    elseif v.LocationType == 2 then
View all 22 lines...

You should get the basic concept on how it works. Test this, and configure it, and you should get what you need.

0
Thank, you so much! FOG20 5 — 9y
0
How can I find the JobId with this? PenguinDevs 45 — 6y
Ad

Answer this question