local players = game:GetService("Players")
local localPlayer = players.LocalPlayer
local friendsWith = {} --array of player instances the local player is friends with
local success, result = pcall(function()
localPlayer:GetFriendsOnline(200)
end)
if success then
if result then
for _, friend in ipairs(result) do
if friend["IsOnline"] then
if friend["GameId"] == game.JobId then
local player = players:FindFirstChild(friend["UserName"])
if player then
table.insert(friendsWith, player)
end
end
end
end
end
end
Here’s a script I wrote yesterday which gets the player’s friends which are currently online in the same server as the player.