This Lua code defines a **dark-themed GUI library** for **Roblox**,...

July 3, 2025 at 05:07 PM

{ "name": "dark_gui_library", "type": "code/lua", "content": "--[[\nModern Dark GUI Library for Roblox\n--]]\n\nlocal DarkUI = {}\nDarkUI.__index = DarkUI\n\nfunction DarkUI:CreateMain(title)\n local screenGui = Instance.new(\"ScreenGui\")\n screenGui.Name = \"DarkUIScreenGui\"\n screenGui.ResetOnSpawn = false\n screenGui.Parent = game:GetService(\"Players\").LocalPlayer:WaitForChild(\"PlayerGui\")\n\n local frame = Instance.new(\"Frame\")\n frame.Name = \"MainFrame\"\n frame.Size = UDim2.new(0, 400, 0, 300)\n frame.Position = UDim2.new(0.5, -200, 0.5, -150)\n frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)\n frame.BorderSizePixel = 0\n frame.AnchorPoint = Vector2.new(0.5, 0.5)\n frame.Parent = screenGui\n\n local uiCorner = Instance.new(\"UICorner\")\n uiCorner.CornerRadius = UDim.new(0, 12)\n uiCorner.Parent = frame\n\n local titleLabel = Instance.new(\"TextLabel\")\n titleLabel.Text = title or \"Dark UI\"\n titleLabel.Size = UDim2.new(1, 0, 0, 40)\n titleLabel.BackgroundTransparency = 1\n titleLabel.TextColor3 = Color3.fromRGB(240, 240, 240)\n titleLabel.Font = Enum.Font.GothamBold\n titleLabel.TextSize = 24\n titleLabel.Parent = frame\n\n local container = Instance.new(\"Frame\")\n container.Name = \"Container\"\n container.Position = UDim2.new(0, 0, 0, 50)\n container.Size = UDim2.new(1, 0, 1, -50)\n container.BackgroundTransparency = 1\n container.Parent = frame\n\n DarkUI._mainFrame = frame\n DarkUI._container = container\n\n return self\nend\n\nfunction DarkUI:CreateButton(text, callback)\n local button = Instance.new(\"TextButton\")\n button.Size = UDim2.new(1, -20, 0, 40)\n button.Position = UDim2.new(0, 10, 0, #self._container:GetChildren() * 45)\n button.BackgroundColor3 = Color3.fromRGB(40, 40, 40)\n button.TextColor3 = Color3.fromRGB(220, 220, 220)\n button.Font = Enum.Font.Gotham\n button.Text = text\n button.TextSize = 18\n button.Parent = self._container\n\n local uiCorner = Instance.new(\"UICorner\")\n uiCorner.CornerRadius = UDim.new(0, 8)\n uiCorner.Parent = button\n\n button.MouseButton1Click:Connect(function()\n if callback then\n callback()\n end\n end)\nend\n\n-- Example usage\nlocal ui = setmetatable({}, DarkUI):CreateMain(\"Dark Mode UI\")\nui:CreateButton(\"Click Me\", function()\n print(\"Button clicked!\")\nend)\n\nreturn DarkUI" }Here is a sleek, modern, dark-themed GUI library for Roblox, along with a sample script demonstrating how to use it. The design is minimalistic and customizable, using `UICorner` for rounded edges and clean layouts. You can expand it further with sliders, toggles, or dropdowns depending on your needs. Let me know if you want additional components or a lighter version.

This Lua code defines a dark-themed GUI library for Roblox, named DarkUI. It creates user interface elements in a modern and minimalistic style, including a main frame and buttons. Here's a breakdown of what the code does:


1. Main Structure

  • The code defines a DarkUI table, which serves as the library containing GUI creation methods. It uses metatables to establish object-oriented behavior.
  • The library methods include:
    • CreateMain(title): Creates a main dark-themed GUI window.
    • CreateButton(text, callback): Allows adding buttons to the GUI with an associated callback function triggered on button clicks.

2. CreateMain(title)

This method creates the main GUI window with the following features:

  • Adds a ScreenGui to the PlayerGui (UI container of the local Roblox player).
  • Creates a dark grey (Color3.fromRGB(20, 20, 20)) main frame that represents the UI window.
  • Configures rounded corners for the main frame using UICorner.
  • Adds a title bar (TextLabel) that displays the provided title or defaults to "Dark UI".
  • Creates a Container frame, which will act as the area to hold other components (like buttons).

3. CreateButton(text, callback)

This method allows you to create buttons dynamically within the Container. Each button:

  • Is styled with a dark background (Color3.fromRGB(40, 40, 40)) and lighter text.
  • Uses rounded corners (UICorner) for a modern appearance.
  • Arranges multiple buttons vertically with a gap between them.
  • Executes a custom callback function when clicked.

4. Example Usage

The provided example demonstrates how to use the library:

  • It creates an instance of the DarkUI class with the main UI title "Dark Mode UI".
  • A single button is added to the UI with the label "Click Me". When clicked, the button will print "Button clicked!" to the output.

Functionality and Features

  • Design: Clean and modern using dark colors and rounded elements (UICorner).
  • Customization: The title of the main frame and button text/callbacks are customizable.
  • Reusability: You can expand the library to include additional UI components like sliders, toggles, or dropdown menus.
  • Roblox Integration: The library uses Roblox's Instance.new API to create UI elements and sets them properly in the player's GUI hierarchy.

Summary

This code defines a reusable, dark-themed Roblox GUI library that handles the creation of clean UI components (main frames and buttons). It is designed to be simple, functional, and expandable for use in creating custom in-game UIs.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node