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.

6 comments

0

Why'd you change the question name?

0

please keep the title in the question name so people can more easily find it if they have a similar question

0

Post your solution so people with the same question can get help.

0

also, you don't really need to update it that often. Maybe every 5 seconds

0

Yeah, here's the solution if anyone needs it: https://pastebin.com/tZYQVKCz

0

didn't get to test it because i have four friends and none of them actually play roblox :(