¡Claro! A continuación, te proporcionaré un simple script de Lua para Roblox que crea una GUI (interfaz gráfica de usuario) y la decora. Este script debe ser ubicado en un LocalScript, normalmente dentro de StarterPlayerScripts o StarterGui.
- Abre Roblox Studio.
- Ve al panel de "Explorer".
- Haz clic derecho en
StarterGui y selecciona "Insert Object" > "LocalScript".
- Copia y pega el siguiente código en el
LocalScript.
local Player = game.Players.LocalPlayer
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Parent = Player:WaitForChild("PlayerGui")
-- Frame principal
local MainFrame = Instance.new("Frame")
MainFrame.Size = UDim2.new(0.5, 0, 0.5, 0)
MainFrame.Position = UDim2.new(0.25, 0, 0.25, 0)
MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
MainFrame.BorderSizePixel = 0
MainFrame.Parent = ScreenGui
-- Título
local TitleLabel = Instance.new("TextLabel")
TitleLabel.Size = UDim2.new(1, 0, 0.2, 0)
TitleLabel.Position = UDim2.new(0, 0, 0, 0)
TitleLabel.BackgroundTransparency = 1
TitleLabel.Text = "Bienvenido a mi GUI"
TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
TitleLabel.Font = Enum.Font.SourceSansBold
TitleLabel.TextSize = 30
TitleLabel.Parent = MainFrame
-- Botón
local Button = Instance.new("TextButton")
Button.Size = UDim2.new(0.8, 0, 0.2, 0)
Button.Position = UDim2.new(0.1, 0, 0.3, 0)
Button.BackgroundColor3 = Color3.fromRGB(50, 150, 50)
Button.BorderSizePixel = 0
Button.Text = "¡Haz Clic Aquí!"
Button.TextColor3 = Color3.fromRGB(255, 255, 255)
Button.Font = Enum.Font.SourceSans
Button.TextSize = 24
Button.Parent = MainFrame
-- Función al hacer clic en el botón
Button.MouseButton1Click:Connect(function()
print("Botón clicado!")
Button.Text = "¡Gracias por hacer clic!"
Button.BackgroundColor3 = Color3.fromRGB(150, 50, 50)
end)
-- Cerrar la GUI al hacer clic fuera del frame
MainFrame.MouseButton1Click:Connect(function()
print("Cerrando GUI...")
ScreenGui:Destroy()
end)
Explicación del script:
- ScreenGui: Crea una nueva GUI en la pantalla del jugador.
- Frame: Es el contenedor principal de la GUI.
- TextLabel: Muestra un título en la parte superior de la GUI.
- TextButton: Un botón interactivo que cambia su texto y color cuando se hace clic.
- Funciones de evento: Al hacer clic en el botón se imprime un mensaje en la consola y se cambia el texto del botón. Además, si se hace clic en el
Frame, la GUI se cierra.
Puedes modificar el diseño, colores y texto según tus necesidades. ¡Espero que esto te sea útil para comenzar a trabajar con GUIs en Roblox!