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

[SOLVED] How to display online friends in game?

Asked by 5 years ago
Edited by RubenKan 5 years ago

So, I was planning my game to have the ability to join the player's friends in different games outside of my game. So if the player wants to know which his/her friends are playing. He will type a TextBox and teleports him/her to his/her friends. I found something on the Developer Roblox website.

And yes, I succeed when I printed the table. But then when I tried putting it on the Text, there is something wrong... It returns only a single friend of my own.

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() 
local dict = player:GetFriendsOnline(10)

while true do
    wait()
    for i, friend in pairs(dict) do
        local number = #dict
        script.Parent.TextLabel.Text = "Friends Online ("..number.."):"
        script.Parent.Text = friend.UserName.." ("..friend.LastLocation..")"
    end
end

I looped it so when a friend is no longer playing, it updates.

0
Why'd you change the question name? hiimgoodpack 2009 — 5y
0
please keep the title in the question name so people can more easily find it if they have a similar question royaltoe 5144 — 5y
0
Post your solution so people with the same question can get help. ForeverBrown 356 — 5y
0
also, you don't really need to update it that often. Maybe every 5 seconds turtle2004 167 — 5y
View all comments (2 more)
0
Yeah, here's the solution if anyone needs it: https://pastebin.com/tZYQVKCz royaltoe 5144 — 5y
0
didn't get to test it because i have four friends and none of them actually play roblox :( royaltoe 5144 — 5y

Answer this question