Roblox GUI Maker logoRoblox GUI Maker
Unofficial third-party tool · Not affiliated with Roblox Corporation

Roblox GUI Luau Code Snippets: Copy-Paste Reference (2026)

2026-07-21 · Roblox GUI Maker Team

Create a ScreenGui programmatically

The foundation of every GUI. Create the ScreenGui, set its properties, and parent it to PlayerGui. ResetOnSpawn = false keeps the GUI alive across respawns.

StarterGui (LocalScript)
lua
1local Players = game:GetService("Players")
2local player = Players.LocalPlayer
3
4local screenGui = Instance.new("ScreenGui")
5screenGui.Name = "MyGui"
6screenGui.ResetOnSpawn = false
7screenGui.IgnoreGuiInset = true
8screenGui.Parent = player:WaitForChild("PlayerGui")

Add a Frame and TextLabel

A centered panel with a title. Use Scale-based sizing and AnchorPoint for true centering.

Add to ScreenGui
lua
1local panel = Instance.new("Frame")
2panel.Size = UDim2.new(0.4, 0, 0.3, 0)
3panel.Position = UDim2.new(0.5, 0, 0.5, 0)
4panel.AnchorPoint = Vector2.new(0.5, 0.5)
5panel.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
6panel.Parent = screenGui
7
8local title = Instance.new("TextLabel")
9title.Size = UDim2.new(1, 0, 0.3, 0)
10title.BackgroundTransparency = 1
11title.Text = "Hello Roblox"
12title.TextColor3 = Color3.fromRGB(255, 255, 255)
13title.TextScaled = true
14title.Parent = panel

Clickable button with feedback

A TextButton that runs a function on click, with a quick press animation for tactile feedback.

Button with press animation
lua
1local button = Instance.new("TextButton")
2button.Size = UDim2.new(0.5, 0, 0.4, 0)
3button.Position = UDim2.new(0.25, 0, 0.4, 0)
4button.BackgroundColor3 = Color3.fromRGB(109, 93, 251)
5button.Text = "Click Me"
6button.TextScaled = true
7button.Parent = panel
8
9button.MouseButton1Click:Connect(function()
10 print("Button clicked!")
11 -- Fire a RemoteEvent to the server for game actions
12end)

TweenService: smooth animation

Animate any GUI property smoothly. The most common pattern is sliding or fading a panel.

TweenService slide-in
lua
1local TweenService = game:GetService("TweenService")
2
3panel.Position = UDim2.new(0.5, 0, 1.5, 0) -- start off-screen
4local tween = TweenService:Create(
5 panel,
6 TweenInfo.new(0.4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out),
7 { Position = UDim2.new(0.5, 0, 0.5, 0) }
8)
9tween:Play()

DataStore: save and load

Persist player data across sessions. Always wrap DataStore calls in pcall to handle failures gracefully.

ServerScriptService (Script)
lua
1local DataStoreService = game:GetService("DataStoreService")
2local Players = game:GetService("Players")
3local store = DataStoreService:GetDataStore("PlayerData")
4
5local function loadData(player)
6 local success, data = pcall(function()
7 return store:GetAsync(player.UserId)
8 end)
9 return (success and data) or { coins = 0 }
10end
11
12local function saveData(player, data)
13 pcall(function()
14 store:SetAsync(player.UserId, data)
15 end)
16end
17
18Players.PlayerAdded:Connect(function(player)
19 local data = loadData(player)
20 print(player.Name, "loaded:", data.coins)
21end)

UIGridLayout: auto-arranged grid

Arrange child elements in a grid automatically. Perfect for inventories, shops, and item lists.

Grid layout
lua
1local grid = Instance.new("UIGridLayout")
2grid.CellSize = UDim2.fromOffset(120, 140)
3grid.CellPadding = UDim2.fromOffset(8, 8)
4grid.FillDirection = Enum.FillDirection.Horizontal
5grid.SortOrder = Enum.SortOrder.LayoutOrder
6grid.Parent = itemContainer
7
8-- Every Frame you parent to itemContainer now arranges in a grid automatically

UIListLayout: vertical stack

Stack elements vertically (or horizontally) with consistent spacing. The standard way to build menus and lists.

List layout
lua
1local list = Instance.new("UIListLayout")
2list.FillDirection = Enum.FillDirection.Vertical
3list.Padding = UDim.new(0, 12)
4list.HorizontalAlignment = Enum.HorizontalAlignment.Center
5list.SortOrder = Enum.SortOrder.LayoutOrder
6list.Parent = menuContainer

Frequently asked questions