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

How to Dynamic GUI creation?

Hi guys; I'm creating a GUI where the user can choose how many lights they want and they can patch them into the GUI. Upon patch if the user has choose to patch in 6 lights then I want the script to create 6 TextButtons in a certain frame. How would I make it so that a script can create a certain amount of gui text buttons in the frame when a button is clicked. The amount can be any number chosen by the user (from 0 to inf.)

If you need any more information then just say. Thanks guys. Golden

1 answer

First of all, sorry for how late this answer is coming but also, you would need to have a TextBox and after the player types in their number, you would have to set the number as a variable. After this, you would create a loop that would copy the text buttons into the frame when the TextButton is clicked. A Script such as the following could be used(but slightly altered to fit your hierarchy). This would be a LocalScript:

player = game.Players.LocalPlayer
gui = player.PlayerGui.ScreenGui.Frame

gui.TextBox.FocusLost:connect(function(enterPressed)
	if enterPressed then
        	local num = tostring(gui.TextBox.Text)
		for i = 1, num do
			game.ServerStorage.TextButton:Clone().Parent = gui
			wait()
		end
   	end
end)

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