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 use GetFriendsOnline()?

1 answer

✓ Accepted answer

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.

2 comments

0

Thank, you so much!

0

How can I find the JobId with this?

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