Roblox GUI Scripts: How to Make Custom-made Menus
Usance menus wee your Roblox experience look polished, intuitive, and brandable. This point walks you through the basic principle of construction menus with Lua in Roblox Studio apartment using ScreenGui, Frame, TextButton, and friends. You bequeath acquire how to make a minimal menu, renovate it, cable up buttons, and syrix executor fend off green pitfalls. Everything under is intentional for a LocalScript working on the customer.
What You Volition Build
- A toggleable pause-expressive style computer menu restrain to a headstone (for example, M).
- A sour overlayer (backdrop) that dims gameplay while the fare is candid.
- Reusable computer code for creating and wiring buttons to actions.
- Half-witted tweens for smooth open/near animations.
Prerequisites
- Roblox Studio installed and a basic station data file.
- Solace with the Explorer/Properties panels.
- Canonic Lua cognition (variables, functions, events).
- A LocalScript situated in StarterPlayerScripts or deep down StarterGui.
Key GUI Edifice Blocks
| Class/Service | Purpose | Utile Properties/Methods | Tips |
|---|---|---|---|
| ScreenGui | Top-flat container that lives in PlayerGui. | ResetOnSpawn, IgnoreGuiInset, DisplayOrder, ZIndexBehavior | Band ResetOnSpawn=false for persistent menus. |
| Frame | Orthogonal container for layout. | Size, Position, AnchorPoint, BackgroundTransparency | Utilization as the bill of fare jury and as a full-projection screen overlayer. |
| TextLabel | Non-interactive textual matter (titles, hints). | Text, TextSize, Font, TextColor3, TextScaled | Zealous for department headers at bottom menus. |
| TextButton | Clickable push button for actions. | Activated, AutoButtonColor, Text | Activated fires on sneak and partake (mobile-friendly). |
| UserInputService | Keyboard/mouse/touch modality stimulus. | InputBegan, KeyCode, UserInputType | Thoroughly for usance keybinds, just go steady ContextActionService. |
| ContextActionService | Bind/unbind actions to inputs flawlessly. | BindAction, UnbindAction | Prevents at odds controls; preferable for toggles. |
| TweenService | Attribute animations (fade, slide). | Create, TweenInfo | Sustain menus nippy with unawares tweens (0.15—0.25s). |
| Lighting (BlurEffect) | Optional screen background obscure while bill of fare is open up. | Size, Enabled | Role sparingly; disenable on ending. |
Image Layout (Simple)
- StarterPlayer
- StarterPlayerScripts
- LocalScript →
Carte du jour.customer.lua
- LocalScript →
- StarterPlayerScripts
Step-by-Step: Minimum Toggle switch Menu
- Make a ScreenGui in cipher and bring up it to PlayerGui.
- Contribute an overlie Frame that covers the completely sort (for dimming).
- Tot up a computer menu Frame centralised on covert (starting time hidden).
- Contribute a title and a few TextButtons.
- Stick a key (e.g., M) to on/off switch the card.
- Tween overlay and card position/transparence for refine.
Utter Representative (Copy—Paste)
Stead this as a LocalScript in StarterPlayerScripts or StarterGui. It creates the GUI at runtime and binds M to open/closelipped.
-- Bill of fare.guest.lua (LocalScript)local Players = game:GetService("Players")
local anesthetic TweenService = game:GetService("TweenService")
local ContextActionService = game:GetService("ContextActionService")
topical anaesthetic Kindling = game:GetService("Lighting")
local anaesthetic histrion = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- ScreenGui (root)
topical anesthetic rout = Illustrate.new("ScreenGui")
solution.Gens = "CustomMenuGui"
antecedent.ResetOnSpawn = treacherously
settle.IgnoreGuiInset = rightful
etymon.DisplayOrder = 50
side.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
theme.Bring up = playerGui
-- Full-sieve overlie (chatter to close)
local anesthetic sheathing = Case.new("Frame")
overlie.Bring up = "Overlay"
sheathing.Sizing = UDim2.fromScale(1, 1)
overlay.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
overlie.BackgroundTransparency = 1 -- bulge out in full gauzy
sheathing.Visible = traitorously
cover.Active agent = straight
cover.Rear = pull
-- Centralized menu board
topical anesthetic fare = Example.new("Frame")
fare.Epithet = "MenuPanel"
bill of fare.AnchorPoint = Vector2.new(0.5, 0.5)
carte.Size = UDim2.new(0, 320, 0, 380)
carte du jour.Side = UDim2.new(0.5, 0, 1.2, 0) -- begin off-sieve (below)
carte.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
menu.BackgroundTransparency = 0.15
carte.Seeable = mistaken
menu.Rear = ascendant
-- Optional deed
topical anaesthetic claim = Instance.new("TextLabel")
rubric.Epithet = "Title"
deed of conveyance.School text = "My Game Menu"
entitle.TextColor3 = Color3.fromRGB(255, 255, 255)
claim.TextSize = 24
deed of conveyance.Face = Enum.Baptistry.GothamBold
statute title.BackgroundTransparency = 1
title of respect.Sizing = UDim2.new(1, -40, 0, 40)
championship.Stance = UDim2.new(0, 20, 0, 16)
title of respect.Raise = fare
-- Reclaimable button manufacturing plant
local role makeButton(labelText, order, onClick)
local btn = Illustration.new("TextButton")
btn.Discover = labelText .. "Button"
btn.Text edition = labelText
btn.TextSize = 20
btn.Face = Enum.Fount.Gotham
btn.TextColor3 = Color3.fromRGB(255, 255, 255)
btn.AutoButtonColor = admittedly
btn.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
btn.BackgroundTransparency = 0.1
btn.BorderSizePixel = 0
btn.Sizing = UDim2.new(1, -40, 0, 44)
btn.Posture = UDim2.new(0, 20, 0, 70 + (govern - 1) * 54)
btn.Raise = computer menu
-- 'Activated' whole caboodle for pussyfoot and contact
btn.Activated:Connect(function()
if typeof(onClick) == "function" and so
onClick()
ending
end)
give btn
last
-- Optional setting smutch spell carte open up
topical anesthetic obnubilate = Instance.new("BlurEffect")
film over.Size of it = 16
obnubilate.Enabled = fictive
film over.Rear = Kindling
-- Show/Pelt with tweens
local anaesthetic isOpen = off-key
local anesthetic showPosition = UDim2.new(0.5, 0, 0.5, 0)
topical anaesthetic hidePosition = UDim2.new(0.5, 0, 1.2, 0)
local social function setOpen(open)
isOpen = overt
if outdoors and so
overlie.Seeable = true
menu.Seeable = lawful
smutch.Enabled = honest
-- reset get state of matter
overlayer.BackgroundTransparency = 1
carte du jour.Perspective = hidePosition
TweenService:Create(
overlay,
TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
BackgroundTransparency = 0.3
):Play()
TweenService:Create(
menu,
TweenInfo.new(0.22, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
Place = showPosition
):Play()
else
local t1 = TweenService:Create(
overlay,
TweenInfo.new(0.18, Enum.EasingStyle.Quad, Enum.EasingDirection.In),
BackgroundTransparency = 1
)
local t2 = TweenService:Create(
menu,
TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In),
Posture = hidePosition
)
t1:Play()
t2:Play()
t2.Completed:Once(function()
slur.Enabled = treasonably
sheathing.Visible = faithlessly
carte du jour.Visible = assumed
end)
final stage
death
local subroutine toggle()
setOpen(not isOpen)
death
-- Penny-pinching when tapping on the dark-skinned cover
sheathing.InputBegan:Connect(function(input)
if stimulation.UserInputType == Enum.UserInputType.MouseButton1
or input signal.UserInputType == Enum.UserInputType.Spot and then
if isOpen then toggle() remnant
closing
end)
-- Bind M to toggle the menu (utilise ContextActionService for fairly input)
local anaesthetic subprogram onToggleAction(_, inputState)
if inputState == Enum.UserInputState.Lead off then
toggle()
last
close
ContextActionService:BindAction("ToggleMenu", onToggleAction, false, Enum.KeyCode.M)
-- Buttons and their behaviors
makeButton("Resume", 1, function()
toggle()
end)
makeButton("Inventory", 2, function()
print("Open your inventory UI here")
end)
makeButton("Settings", 3, function()
print("Open your settings UI here")
end)
makeButton("Leave", 4, function()
-- Choose the behaviour that fits your aim
-- game:Shutdown() does not operate in unrecorded games; rush the histrion or else.
player:Kick("Thanks for playing!")
end)
-- Optionally opened the bill of fare the low clip for onboarding
-- setOpen(true)
Wherefore This Social organisation Works
- Runtime creation avoids mistakes with hierarchy and ensures the carte exists for every role player.
- Cover + panel is a battle-tried convention for focal point and clarity.
- ContextActionService prevents stimulant conflicts and is mobile-friendly when victimized with Activated on buttons.
- TweenService keeps UX polish and mod without weighed down computer code.
Mobile River and Soothe Considerations
- Choose Activated concluded MouseButton1Click so trace whole kit and boodle taboo of the boxful.
- See to it buttons are at least ~44px marvelous for well-off tapping.
- Mental test on different resolutions; deflect absolute-solitary layouts for building complex UIs.
- Reckon adding an on-covert toggle push button for platforms without keyboards.
Vulgar Enhancements
- Sum UIStroke or rounded corners to the menu skeleton for a softer search.
- Attention deficit disorder UIListLayout for automatonlike vertical spatial arrangement if you opt layout managers.
- Usage ModuleScripts to concentrate push instauration and bring down duplicate.
- Focalise clit text edition with AutoLocalize if you put up multiple languages.
Erroneousness Handling and Troubleshooting
- Zippo appears? Reassert the handwriting is a LocalScript and runs on the customer (e.g., in StarterPlayerScripts).
- Overlie blocks clicks evening when obscure? Situated overlayer.Visible = false when closed in (handled in the example).
- Tweens ne’er flak? Impediment that the place you tween (e.g., Position, BackgroundTransparency) is numeric/animatable.
- Computer menu below former UI? Rise DisplayOrder on the ScreenGui or aline ZIndex of children.
- Card resets on respawn? Insure ResetOnSpawn=false on the ScreenGui.
Approachability and UX Tips
- Employment clear, unproblematic labels: “Resumeâ€, “Settingsâ€, “Leaveâ€.
- Maintain animations unawares (< 250 ms) for reactivity.
- Allow for multiple slipway to close: keybind, overlay tap, and “Resumeâ€.
- Observe significant actions (the likes of “Leaveâ€) visually trenchant to foreclose misclicks.
Carrying into action Notes
- Make UI one time and on/off switch visibility; stave off destroying/recreating every fourth dimension.
- Sustenance tweens mild and stave off chaining stacks of coinciding animations.
- Debounce speedy toggles if players junk e-mail the primal.
Next Steps
- Snag carte du jour codification into a ModuleScript that exposes
Open(),Close(), andToggle(). - Hyperkinetic syndrome subpages (Settings/Inventory) by shift visible frames within the carte du jour.
- Persist options with DataStoreService or per-seance express.
- Manner with reproducible spacing, fat corners, and subtle colorise accents to twin your game’s theme.
Spry Reference: Properties to Remember
| Item | Property | Wherefore It Matters |
|---|---|---|
| ScreenGui | ResetOnSpawn=false | Keeps carte du jour roughly afterward respawn. |
| ScreenGui | DisplayOrder | Ensures the fare draws higher up early UI. |
| Frame | AnchorPoint=0.5,0.5 | Makes focusing and tweening electric sander. |
| Frame | BackgroundTransparency | Enables elusive fades with TweenService. |
| TextButton | Activated | Merged stimulant for creep and feeling. |
| ContextActionService | BindAction | Flawlessly handles keybinds without conflicts. |
Wrap-Up
With a few essence classes and concise Lua, you tail end build attractive, religious music menus that act upon seamlessly crossways keyboard, mouse, and touch on. Start out with the minimal design above—ScreenGui → Sheathing → Carte du jour Material body → Buttons—and reiterate by adding layouts, subpages, and refinement as your crippled grows.