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

How to get UserId from :GetOnlineFriends()?

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
1
Answered by
rabbi99 714 Moderation Voter
3 years ago

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
0
Hm, very interesting. It works tho! Thank you a lot for your help! ggAmazingMan 32 — 3y
Ad

Answer this question