Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a scrollingframe that automatically adds buttons?

How do I make a scrollingframe that automatically adds buttons from a folder in the replicatedstorage?

5 comments

0

your question does not make any sense.

0

how does it not

0

You have a scrolling frame that you want to have a button in for each of whatever you have in your folder that is inside ReplicatedStorage, correct?

0

yes

0

This is not a request site; Please try to attempt it instead of asking how to do it first. Google it and find your answer, if the code you used doesn't work, make a question and people will help you

1 answer

I'm assuming you mean that you have a folder of objects in ReplicatedStorage and you want to create a ScrollingFrame with a button for each object. If so, the easiest way would be to create a for loop that loops through each object and creates a button for it.

-- Make sure this is in a LocalScript

local frame = Instance.new("ScrollingFrame", game.Players.LocalPlayer.PlayerGui.ScreenGui) -- Make sure you create a screengui to put this in
frame.Size = UDim2.new(0, 125, 0, 100)

Instance.new("UIListLayout", frame) -- Automatically spaces the buttons for you

for _,v in pairs(game.ReplicatedStorage.YOURFOLDER:GetChildren()) do
	local button = Instance.new("TextButton", frame)
	button.Text = v.Name
	button.Size = UDim2.new(1,0,25,0)
end

frame.CanvasSize = UDim2.new(1,0,0,#game.ReplicatedStorage.YOURFOLDER:GetChildren()*25)

You can edit the values of the size and position of the objects in there as needed to fit your needs.

If you're looking for more information, the developer wiki has plenty of resources:

https://developer.roblox.com/articles/Creating-a-Scrolling-Frame-GUI https://developer.roblox.com/articles/Fundamentals-of-Scripting-with-GUIs https://developer.roblox.com/articles/Creating-GUI-Buttons

This discussion is preserved as it was. New answers, comments, and votes are closed.