Hihi! I am making a FPS game, however I am having dificulties in the friends list.
Question is, How am i able to make a scrolling frame that shows all your friends that is in the game you are currently in.
In the game, or in the server?
You can use the Player | Roblox Creator Documentation function in a local script. Then, in the ScrollingFrame | Roblox Creator Documentation, you can insert a UIListLayout | Roblox Creator Documentation instance.
Also, you will want to have a base template for what you want each friend name to look like in the ScrollingFrame
. For this example I will pretend to be using a Frame | Roblox Creator Documentation with a TextLabel | Roblox Creator Documentation and ImageLabel | Roblox Creator Documentation.
Also, because it doesn’t matter what order the friends come in, it’d be best to set the UIGridStyleLayout | Roblox Creator Documentation propert to Name
Here’s an example in a LocalScript | Roblox Creator Documentation.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local scrollingFrame = --path to scrolling frame
local listLayout = scrollingFrame:FindFirstChildWhichIsA("UIListLayout")
local friendTemplate = --path to frame object containing the text label and image label
local friendList = {}
local function filterPlayer(userId)
if player:IsFriendsWith(userId) then
local friend = friendTemplate:Clone() do
friend.TextLabel.Text = player.DisplayName
friend.ImageLabel.Image = player:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size48x48)
friend.Parent = scrollingFrame
end
friendList[userId] = friend
end
end
for _, player in pairs(Players:GetPlayers()) do
filterPlayer(player.UserId)
end
Players.PlayerAdded:Connect(function(player)
filterPlayer(player.UserId)
end)
Players.PlayerRemoving:Connect(function(player)
local friend = friendList[player.UserId]
if friend then
friend:Destroy()
end
end)
This code is untested, so it may not work first try.
Also, this isn’t the only way to get your friends in the game. There are other methods such as Player | Roblox Creator Documentation and Player | Roblox Creator Documentation, although GetFriendStatus
hasn’t been released yet.
I am trying to make it so it would show if they are in the same game and not the same server. How am I able to implement that?
Cross-Server technically saying game. How am I able to do so?
One way would be to use Player:GetFriendsOnline() and go through the table, checking the PlaceId of the place where each online friend is currently located in to see if they’re playing your game at the moment.