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
8 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
8 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: **

local plr = game.Players.LocalPlayer

for i,v in pairs (plr:GetFriendsOnline()) do
    print(" ") -- New Line (Making it look pretty in Output) 
    if v.VisitorId then
    print("Friend #"..i, " id is "..v.VisitorId) -- Get their userId
    end
    if v.PlaceId then
    print(" Last Place Visited Was: "..v.PlaceId) -- Get the place id of the game they're playing.
    end
    if v.LocationType == 0 then -- Checking location type
        print(" Is on mobile website")
    elseif v.LocationType == 1 then
        print(" Is in mobile game")
    elseif v.LocationType == 2 then
        print(" Is on website")
    elseif v.LocationType == 3 then
        print(" Is in studio")
    elseif v.LocationType == 4 then
        print(" Is ingame")
    end
end

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 — 8y
0
How can I find the JobId with this? PenguinDevs 45 — 6y
Ad

Answer this question