Set core GUI Roblox
-- Creating a ScreenGui (top-level GUI object)
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
-- Creating a Frame GUI object
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.5, 0, 0.5, 0) -- Setting size relative to the screen
frame.Position = UDim2.new(0.25, 0, 0.25, 0) -- Setting position relative to the screen
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- Setting background color to red
frame.Parent = screenGui -- Setting the parent of the frame to the ScreenGui
-- Creating a TextLabel GUI object as a child of the Frame
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0) -- Setting size to fill the Frame
textLabel.Text = "Hello, Roblox Lua!" -- Setting the text content
textLabel.TextColor3 = Color3.new(1, 1, 1) -- Setting text color to white
textLabel.Parent = frame -- Setting the parent of the TextLabel to the Frame
This Lua script creates a simple GUI in Roblox using the core GUI system. It starts by creating a ScreenGui
as the top-level GUI object and then adds a Frame
as a child of the ScreenGui
. Inside the Frame
, a TextLabel
is created to display the text "Hello, Roblox Lua!" The script sets properties such as size, position, background color, and text color for these GUI elements.