Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get UserId from :GetOnlineFriends()?

Hello! I've been working on an in-game friendslist recently.

For some reason, I cannot get the UserId of a user. Here is my script;

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local onlineFriends = player:GetFriendsOnline(8)


for i, friend in pairs(onlineFriends) do
	print(friend.UserId)
end

Output just prints nil.

For some weird reason, friend.UserName works, but friend.UserId doesn't. How could I get the userid?

1 answer

✓ Accepted answer

To get the UserId of a friend you must use VisitorId, not sure why Roblox decided to do it like that. But it is what it is!

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local onlineFriends = player:GetFriendsOnline(8)


for i, friend in pairs(onlineFriends) do
    print(friend.VisitorId)
end

1 comment

0

Hm, very interesting. It works tho! Thank you a lot for your help!

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