Hi there, I want to know how I would go about making my own send friend request button for a custom leaderboard I’ve made. There is absolutely nothing about this from what I can see on DevHub and YouTube, however I know that this does exist, a couple of games like @Wsly’s Deathrun have implemented this.
Screenshot:
Code:
local lib = game.Players:GetChildren()
for i, v in ipairs(lib) do
script.Parent.CanvasSize = UDim2.new(0, 0, 0, script.Parent.CanvasSize.Y.Offset + 40)
local obj = game.ReplicatedStorage.Template:Clone()
obj.Parent = script.Parent
obj.Visible = true
obj.Name = "@"..v.Name
obj.TextLabel.Text = "@"..v.Name
local userid = v.UserId
local thumbtype = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userid, thumbtype, thumbSize)
obj.ImageLabel.Image = content
end
game.Players.PlayerAdded:Connect(function(player)
wait(0.5)
script.Parent.CanvasSize = UDim2.new(0, 0, 0, script.Parent.CanvasSize.Y.Offset + 40)
local obj = game.ReplicatedStorage.Template:Clone()
obj.Parent = script.Parent
obj.Visible = true
obj.Name = "@"..player.Name
obj.TextLabel.Text = "@"..player.Name
local userid = player.UserId
local thumbtype = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userid, thumbtype, thumbSize)
obj.ImageLabel.Image = content
end)
game.Players.PlayerRemoving:Connect(function(player)
script.Parent.CanvasSize = UDim2.new(0, 0, 0, script.Parent.CanvasSize.Y.Offset - 40)
local par = script.Parent
local name = "@"..player.Name
local object = par:FindFirstChild(name)
object:Destroy()
end)
Thanks in advance!