How to make a text button that creates another text button?
You need to use the Instance.new
function in order to create ROBLOX Objects (or Instances) from Lua code. Aftering 'Instancing' it, you can code its properties and listen to its events like any other ROBLOX Object:
local button = script.Parent local newButton = nil button.MouseButton1Click:connect(function() if newButton then newButton:Destroy() end local random = math.floor(math.random()*100) newButton = Instance.new("TextButton") newButton.Size = UDim2.new(0, 500, 0, 250) newButton.Text = "Another example of setting a property" newButton.Parent = script.Parent.Parent newButton.MouseButton1Click:connect(function() print("New Button Clicked! " .. random) end) end)