A gradient background transforms a plain menu into something players notice. UIGradient lets you blend two or more colors smoothly across any GuiObject. It's one of the easiest ways to make your game look more polished.
This tutorial walks you through building a functional main menu with gradient effects on buttons and panels. You'll learn where UIGradient lives in the GUI hierarchy, how to configure colors and rotation, and how to style multiple elements consistently.
Understanding UIGradient
UIGradient is a special GUI object that applies a color gradient to its parent element. Every gradient needs:
- Color sequence: Two or more color stops that define the gradient palette
- Rotation: The angle of the gradient (0° is left-to-right, 90° is top-to-bottom)
- Transparency sequence: Optional transparency stops for fade effects
Key fact: UIGradient doesn't replace the parent's background color — it layers on top. If you want the gradient to show clearly, set the parent's BackgroundColor3 to white or the brightness won't match your expectations.
Setting Up the Main Menu Structure
Start by creating a basic frame hierarchy. In Roblox Studio:
- In StarterGui, right-click and insert a ScreenGui named "MainMenu"
- Inside MainMenu, add a Frame named "MenuPanel" — set Size to {1, 0}, {1, 0} to fill the screen
- Inside MenuPanel, add another Frame named "ButtonContainer" — use {0, 300}, {0, 400} for a column of buttons
This nesting keeps your menu organized. The ButtonContainer will hold individual buttons with gradients.
Applying UIGradient to the Background
Let's add a gradient to your main background panel:
- Select MenuPanel in the Explorer
- Right-click and Insert Object → UIGradient
- Set MenuPanel's BackgroundColor3 to white (255, 255, 255) so the gradient displays at full intensity
- In the UIGradient properties, locate the Color sequence
Click the Color sequence field to open the editor. Add two color stops:
- Stop 0.0: Dark blue (0, 50, 150)
- Stop 1.0: Light purple (100, 50, 200)
Set Rotation to 45 degrees for a diagonal blend. You'll see the preview update in the viewport immediately.
Creating Gradient Buttons
Now add buttons inside ButtonContainer. Each button will have its own subtle gradient:
- Inside ButtonContainer, insert a TextButton named "PlayButton"
- Set Size to {0, 280}, {0, 50} with some Padding
- Set TextScaled to true and Text to "Play"
- Set BackgroundColor3 to white
- Right-click PlayButton → Insert Object → UIGradient
For the button gradient, use a subtle color scheme:
- Stop 0.0: Bright green (50, 200, 100)
- Stop 1.0: Darker green (30, 150, 80)
Keep Rotation at 0 (left-to-right) for button gradients — it feels more natural when the gradient runs across the button width. Duplicate this button and change the text to "Settings" and "Quit", then adjust their gradient colors as needed.
Using Transparency in Gradients
Transparency sequences add polish. You can fade a gradient from fully opaque to transparent, creating overlay effects:
- Select a button's UIGradient
- In the properties, click the Transparency sequence field
- Set Stop 0.0 to 0.0 (fully opaque)
- Set Stop 1.0 to 0.3 (30% transparent)
This makes the gradient fade out toward one end, useful for layered backgrounds or creating a "highlight" effect on buttons when players hover over them.
Scripting Interactive Gradient Changes
You can change gradients dynamically with Lua. Here's a script that shifts button gradient colors on hover:
local button = script.Parent
local gradient = button:WaitForChild("UIGradient")
-- Store original colors
local originalColor = gradient.Color
-- Create a new color sequence for hover state
local hoverColor = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromRGB(100, 220, 150)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(50, 170, 100))
}
button.MouseEnter:Connect(function()
gradient.Color = hoverColor
end)
button.MouseLeave:Connect(function()
gradient.Color = originalColor
end)This script waits for the UIGradient to exist, stores the original color sequence, then swaps it when the mouse enters or leaves the button. The gradient smoothly transitions because Roblox animates property changes by default.
Centering and Positioning UI
Use UIPadding and UIListLayout to keep your menu organized:
- Inside ButtonContainer, insert UIListLayout
- Set Padding to {0, 10}, {0, 10} (10 pixels between buttons)
- Set FillDirection to Vertical and Justify to Center
- Add UIPadding with Padding {0, 20}, {0, 30} to add margins
These layouts automatically space and align your buttons, so you don't manually position each one. If you add or remove buttons later, the layout adjusts automatically.
Common Gradient Mistakes
Gradient not showing: Set the parent element's BackgroundColor3 to white or a bright color. A dark background dims the gradient.
Gradient looks washed out: Use higher contrast colors in your ColorSequence. Pastels and similar shades blend invisibly.
Gradient overshoots corners: This is normal behavior. If it bothers you, set the parent's ClipsDescendants to true.
Rotation doesn't match expectations: Remember that 0° is left-to-right. Horizontal button gradients work best at 0°, while panel backgrounds often look better at 45° or 90°.
Next Steps
Once your main menu looks good, connect buttons to actual game functions. Hook the PlayButton to teleport players into the game, Settings to open options, and Quit to close the game.
Consider adding animations: fade the menu in on load, scale buttons slightly when clicked, or slide the entire menu from off-screen. UIGradient pairs beautifully with these effects.
For advanced styling, layer multiple UIGradients (one per color scheme) and toggle which one is visible using the Visible property, or animate the Rotation property to create spinning gradient effects.