Hello, So last night I had a idea where in a game there is a UI that when pressed/clicked Opens a ScreenGUI and in it there are buttons but you might ask what are so special about these buttons?
Well these buttons are labelled with the players friends and when pressed/clicked changes the player into the friend that they picked.
I was wondering how would I manage to do this because I would need to make it add buttons depending on the amount of friends they have.
Any help on how I would do this is very appreciated.
So basically you want to load up a player’s friend list and each button being a friend if they click on one of their friends via button they transform into them?
You can achieve this by using a ScrollingFrame and formatting 1 TextButton inside of the ScrollingFrame and then put it somewhere else, for example, [ReplicatedStorage],(ReplicatedStorage | Roblox Creator Documentation) and make a script that goes through the Friends list and retrieves the button from ReplicatedStorage and clones it x times (x is how many friends there are). For every clone, parent it to the ScrollingFrame and change the name to the text name of the friend.
If you need help making the script, let me know and I can help you.
You could use a UIListLayout along with a ScrollingFrame. Just clone an example button template for each friend in their friends list and parent it to the ScrollingFrame.
Thanks, All I need help with is when the player presses/clicks the button they change into there freinds avatar.
I believe I can do the buttons showing and appearing with the players freinds usernames but I might struggle.
local Players = game:GetService("Players")
local event = game:GetService("ReplicatedStorage"):FindFirstChild("AvatarChange")
event.OnServerEvent:Connect(function(player,userid)
local description = Players:GetHumanoidDescriptionFromUserId(userid)
player.Character:FindFirstChild("Humanoid"):ApplyDescription(description)
end)
LocalScript:
local button = script.Parent
local event = game:GetService("ReplicatedStorage"):FindFirstChild("AvatarChange")
button.MouseButton1Click:Connect(function(player)
local userid = button:GetAttribute("UserId")
event:FireServer(userid)
end)
Btw there is a Attribute in the TextButton called UserId. When you clone for each friend, set that attribute to that friend’s userid