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

how to get the players friends?

Asked by
TNTeon -1
6 years ago

I need to get all the players friends and I have no idea how! I need only the friends that are online playing the game at that moment. Please someone help! I need this so if they want they can transfer to the same team

0
player:GetOnlineFriends() UgOsMiLy 1074 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
local Player = game:GetService('Players').LocalPlayer -- Get the Player

local PlayersFriends = Player:GetOnlineFriends() -- This is how.



But in your case, since you need to allow them to transfer to the same team, you would need this.

local Players = game:GetService(Players)

local PlayersinPlayers = Players:GetPlayers() -- get the players

local AbleTeams = {}

for i, v in pairs(PlayersinPlayers) do -- and an example of how you can do it
    if v ~= Players.LocalPlayer and Players.LocalPlayer:IsFreindsWith(v.UserId) then
        table.insert(AbleTeams, v.Team)
    end
end

--i think you can do it from here
Ad

Answer this question