Template
Roblox main menu template
A centred menu panel with a title and four stacked buttons, each already connected to a click handler you replace with your own logic.
ScreenGui › MenuPanel › Play / Shop / Settings / Credits · UIListLayout + UIPadding
A main menu is the first thing a player clicks, and it is usually the last thing a Roblox developer builds. This template hands you the structure — a titled panel with four stacked buttons and click handlers already wired — so you can spend your time on the game instead.
What the code builds
A ScreenGui named BuildGUIMenu, a MenuPanel frame about a third of the screen wide, a TextLabel for the title, and four TextButton instances stacked by a UIListLayout with a UIPadding top offset so the buttons start below the title. Each button gets a UICorner and a MouseButton1Click handler that prints its name — replace that print with your own logic.
local list = Instance.new("UIListLayout")
list.Padding = UDim.new(0, 8)
list.SortOrder = Enum.SortOrder.LayoutOrder
list.Parent = panel
local pad = Instance.new("UIPadding")
pad.PaddingTop = UDim.new(0, 46)
pad.PaddingLeft = UDim.new(0, 16)
pad.PaddingRight = UDim.new(0, 16)
pad.Parent = panel
for i, text in ipairs({ "Play", "Shop", "Settings", "Credits" }) do
local button = Instance.new("TextButton")
button.Name = text .. "Button"
button.LayoutOrder = i
button.Size = UDim2.new(1, -32, 0, 44)
button.Text = text
button.Parent = panel
button.MouseButton1Click:Connect(function()
print(text .. " pressed") -- replace with your own logic
end)
end
Wiring a button to a real action
The generated handler is a placeholder. In a real game the play button usually hides the menu and spawns the player:
local play = panel:WaitForChild("PlayButton")
play.MouseButton1Click:Connect(function()
panel.Visible = false
-- start the round, teleport the character, open the lobby, etc.
end)
If a button needs to tell the server something (buying a pass, joining a queue), fire a RemoteEvent from the handler instead of doing the work on the client.
Sizing that survives a phone
The menu panel is positioned with fromScale(0.5, 0.5) and an AnchorPoint of (0.5, 0.5), which centres it without any resolution-specific maths. The buttons use UDim2.new(1, -32, 0, 44): full width minus the padding, 44 pixels tall. 44 is the smallest tap target that stays comfortable on a phone — go smaller and players will miss the button.
Common mistakes
- Buttons taller or shorter than the panel. A
UIListLayoutwith six buttons in a 200px panel overflows. Either raise the panel height or reduce the button height. - No
LayoutOrder. Without it the buttons keep the order they were created in, which stops matching your design the moment you reorder the loop. - Connecting to a button that does not exist yet. Use
panel:WaitForChild("ShopButton")instead ofpanel.ShopButton, or the script can error on the first frame. - Leaving the menu visible. Set
panel.Visible = falsewhen the game starts, and turn it back on from the pause menu.
Where to go next
Open the GUI maker, choose Main menu and set your accent colour — the code updates as you drag the slider. The shop and inventory templates are the natural next panels to build.