Advertisement
AlphaTwo_gg

Untitled

Jun 3rd, 2025
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.34 KB | None | 0 0
  1. --[[
  2. LunarZ Modular UI Library
  3. Features:
  4. 🧩 Components:
  5. • Button
  6. • Toggle
  7. • Window
  8. • Tab (preserves line before name)
  9. • Section
  10. • Slider
  11. • Dropdown
  12. • TextBox
  13. • ColorPicker
  14. • Keybind
  15. • Label
  16. • Paragraph
  17. ⚙️ Additional:
  18. • Config system (save/load UI states via DataStoreService)
  19. • Theme system (default “HollowPurple” theme preserved; easy to add more)
  20. • Webhook support (HttpService.PostAsync)
  21. 🔧 Requirements:
  22. • Keeps all existing design and animations exactly as before
  23. • Maintains line before tab names
  24. • Organized in a clean, modular library structure
  25. • Full, unabridged script below—nothing omitted
  26. --]]
  27.  
  28. -----------------------------
  29. -- UI LIBRARY (ModuleTable)
  30. -----------------------------
  31. local UILibrary = {}
  32. UILibrary.__index = UILibrary
  33.  
  34. -- Services
  35. local Players = game:GetService("Players")
  36. local TweenService = game:GetService("TweenService")
  37. local RunService = game:GetService("RunService")
  38. local HttpService = game:GetService("HttpService")
  39. local DataStoreService = game:GetService("DataStoreService")
  40.  
  41. -- Config DataStore
  42. local ConfigStore = DataStoreService:GetDataStore("LunarZ_UI_ConfigStore")
  43.  
  44. -- Default Themes
  45. UILibrary.Themes = {
  46. HollowPurple = {
  47. BackgroundColor = Color3.fromRGB(15, 10, 25),
  48. InnerBackgroundColor = Color3.fromRGB(8, 5, 15),
  49. SidebarColor = Color3.fromRGB(18, 12, 30),
  50. AccentColor = Color3.fromRGB(75, 35, 130),
  51. TextPrimary = Color3.fromRGB(245, 240, 255),
  52. TextSecondary = Color3.fromRGB(200, 190, 220),
  53. Highlight = Color3.fromRGB(186, 85, 211),
  54. ScrollbarColor = Color3.fromRGB(138, 43, 226),
  55. LogoColor = Color3.fromRGB(186, 85, 211),
  56. LogoSubtextColor = Color3.fromRGB(147, 112, 219),
  57. HeaderColor = Color3.fromRGB(18, 12, 30),
  58. ContentColor = Color3.fromRGB(12, 8, 20),
  59. BorderThickness = 3,
  60. GlowColors = {Color3.fromRGB(75, 0, 130), Color3.fromRGB(138, 43, 226)},
  61. GlowTransparencies = {0.6, 0.8},
  62. GlowThicknesses = {2, 1},
  63. StrokeInitial = Color3.fromRGB(0, 100, 255),
  64. StrokeTransparency = 0.2,
  65. AnimationSpeed = 0.2,
  66. },
  67. -- Example for adding more themes:
  68. -- DarkBlue = { ... }
  69. }
  70.  
  71. -- Utility: Smoothstep interpolation
  72. local function smoothStep(alpha)
  73. return alpha * alpha * (3 - 2 * alpha)
  74. end
  75.  
  76. -- Interpolate between two Color3 with smoothstep
  77. local function lerpColor(c1, c2, alpha)
  78. local s = smoothStep(alpha)
  79. return Color3.new(
  80. c1.R + (c2.R - c1.R) * s,
  81. c1.G + (c2.G - c1.G) * s,
  82. c1.B + (c2.B - c1.B) * s
  83. )
  84. end
  85.  
  86. -- Color sequence for RGB animation (same as original)
  87. local function getColorSequence(theme)
  88. return {
  89. {time = 0.1, color = theme.StrokeInitial}, -- Blue start
  90. {time = 0.2, color = Color3.fromRGB(40, 70, 235)}, -- Blue cooling
  91. {time = 0.3, color = Color3.fromRGB(60, 55, 225)}, -- Blue-purple
  92. {time = 0.4, color = Color3.fromRGB(80, 40, 215)}, -- Towards purple
  93. {time = 0.5, color = Color3.fromRGB(100, 30, 200)}, -- Purple emerging
  94. {time = 0.6, color = Color3.fromRGB(120, 35, 190)}, -- Mid purple
  95. {time = 0.7, color = Color3.fromRGB(140, 40, 180)}, -- Purple deepening
  96. {time = 0.8, color = Color3.fromRGB(160, 45, 165)}, -- Purple-red start
  97. {time = 0.9, color = Color3.fromRGB(200, 50, 120)}, -- Towards red
  98. {time = 1.0, color = Color3.fromRGB(255, 50, 50)}, -- Red
  99. }
  100. end
  101.  
  102. -- Config handling: Save UI state (component values) for this player under given name
  103. function UILibrary:SaveConfig(configName, stateTable)
  104. -- stateTable: table mapping component identifiers to their values (booleans, numbers, color3 as string, etc.)
  105. local success, err = pcall(function()
  106. local key = tostring(self.Player.UserId) .. "_" .. configName
  107. local jsonData = HttpService:JSONEncode(stateTable)
  108. ConfigStore:SetAsync(key, jsonData)
  109. end)
  110. if not success then
  111. warn("Failed to save config:", err)
  112. end
  113. end
  114.  
  115. -- Config handling: Load UI state as a table (or nil)
  116. function UILibrary:LoadConfig(configName)
  117. local result = nil
  118. local success, dataOrErr = pcall(function()
  119. local key = tostring(self.Player.UserId) .. "_" .. configName
  120. return ConfigStore:GetAsync(key)
  121. end)
  122. if success and dataOrErr then
  123. local ok, decoded = pcall(function()
  124. return HttpService:JSONDecode(dataOrErr)
  125. end)
  126. if ok then
  127. result = decoded
  128. end
  129. elseif not success then
  130. warn("Failed to load config:", dataOrErr)
  131. end
  132. return result
  133. end
  134.  
  135. -- Webhook support: send arbitrary JSON data table
  136. function UILibrary:SendWebhook(webhookUrl, payloadTable)
  137. local success, result = pcall(function()
  138. local jsonPayload = HttpService:JSONEncode(payloadTable)
  139. return HttpService:PostAsync(webhookUrl, jsonPayload)
  140. end)
  141. if not success then
  142. warn("Failed to send webhook:", result)
  143. end
  144. end
  145.  
  146. -- Create a new Window instance
  147. function UILibrary.NewWindow(playerGui, windowTitle, themeName)
  148. local self = setmetatable({}, UILibrary)
  149. self.Player = Players.LocalPlayer
  150. self.Gui = playerGui or self.Player:WaitForChild("PlayerGui")
  151. self.Theme = UILibrary.Themes[themeName or "HollowPurple"]
  152. assert(self.Theme, "Theme " .. tostring(themeName) .. " not found")
  153. self.WindowTitle = windowTitle or "LunarZ Hub"
  154. self.Tabs = {}
  155. self:IsMinimized = false
  156. self.Dragging = false
  157. self.DragStart = nil
  158. self.StartPos = nil
  159. self.Time = 0
  160. self.ColorSeq = getColorSequence(self.Theme)
  161.  
  162. -- Create ScreenGui
  163. local screenGui = Instance.new("ScreenGui")
  164. screenGui.Name = "LunarZHub"
  165. screenGui.Parent = self.Gui
  166. screenGui.ResetOnSpawn = false
  167. self.ScreenGui = screenGui
  168.  
  169. -- Main Frame
  170. local mainFrame = Instance.new("Frame")
  171. mainFrame.Name = "MainFrame"
  172. mainFrame.Size = UDim2.new(0, 804, 0, 504)
  173. mainFrame.Position = UDim2.new(0.5, -402, 0.5, -252)
  174. mainFrame.BackgroundColor3 = self.Theme.BackgroundColor
  175. mainFrame.BorderSizePixel = 0
  176. mainFrame.Parent = screenGui
  177. self.MainFrame = mainFrame
  178.  
  179. local mainCorner = Instance.new("UICorner")
  180. mainCorner.CornerRadius = UDim.new(0, 12)
  181. mainCorner.Parent = mainFrame
  182.  
  183. -- Stroke for animated border
  184. local mainStroke = Instance.new("UIStroke")
  185. mainStroke.Color = self.Theme.StrokeInitial
  186. mainStroke.Thickness = self.Theme.BorderThickness
  187. mainStroke.Transparency = self.Theme.StrokeTransparency
  188. mainStroke.Parent = mainFrame
  189. self.MainStroke = mainStroke
  190.  
  191. -- Glow layers
  192. -- Layer 1
  193. local glowFrame1 = Instance.new("Frame")
  194. glowFrame1.Name = "GlowFrame1"
  195. glowFrame1.Size = UDim2.new(1, 6, 1, 6)
  196. glowFrame1.Position = UDim2.new(0, -3, 0, -3)
  197. glowFrame1.BackgroundTransparency = 1
  198. glowFrame1.BorderSizePixel = 0
  199. glowFrame1.Parent = mainFrame
  200. self.GlowFrame1 = glowFrame1
  201.  
  202. local glowStroke1 = Instance.new("UIStroke")
  203. glowStroke1.Color = self.Theme.GlowColors[1]
  204. glowStroke1.Thickness = self.Theme.GlowThicknesses[1]
  205. glowStroke1.Transparency = self.Theme.GlowTransparencies[1]
  206. glowStroke1.Parent = glowFrame1
  207. self.GlowStroke1 = glowStroke1
  208.  
  209. local glowCorner1 = Instance.new("UICorner")
  210. glowCorner1.CornerRadius = UDim.new(0, 15)
  211. glowCorner1.Parent = glowFrame1
  212.  
  213. -- Layer 2
  214. local glowFrame2 = Instance.new("Frame")
  215. glowFrame2.Name = "GlowFrame2"
  216. glowFrame2.Size = UDim2.new(1, 10, 1, 10)
  217. glowFrame2.Position = UDim2.new(0, -5, 0, -5)
  218. glowFrame2.BackgroundTransparency = 1
  219. glowFrame2.BorderSizePixel = 0
  220. glowFrame2.Parent = mainFrame
  221. self.GlowFrame2 = glowFrame2
  222.  
  223. local glowStroke2 = Instance.new("UIStroke")
  224. glowStroke2.Color = self.Theme.GlowColors[2]
  225. glowStroke2.Thickness = self.Theme.GlowThicknesses[2]
  226. glowStroke2.Transparency = self.Theme.GlowTransparencies[2]
  227. glowStroke2.Parent = glowFrame2
  228. self.GlowStroke2 = glowStroke2
  229.  
  230. local glowCorner2 = Instance.new("UICorner")
  231. glowCorner2.CornerRadius = UDim.new(0, 17)
  232. glowCorner2.Parent = glowFrame2
  233.  
  234. -- Inner Frame (content container)
  235. local innerFrame = Instance.new("Frame")
  236. innerFrame.Name = "InnerFrame"
  237. innerFrame.Size = UDim2.new(1, -4, 1, -4)
  238. innerFrame.Position = UDim2.new(0, 2, 0, 2)
  239. innerFrame.BackgroundColor3 = self.Theme.InnerBackgroundColor
  240. innerFrame.BorderSizePixel = 0
  241. innerFrame.Parent = mainFrame
  242. self.InnerFrame = innerFrame
  243.  
  244. local innerCorner = Instance.new("UICorner")
  245. innerCorner.CornerRadius = UDim.new(0, 10)
  246. innerCorner.Parent = innerFrame
  247.  
  248. -- Sidebar
  249. local sidebar = Instance.new("Frame")
  250. sidebar.Name = "Sidebar"
  251. sidebar.Size = UDim2.new(0, 180, 1, 0)
  252. sidebar.BackgroundColor3 = self.Theme.SidebarColor
  253. sidebar.BorderSizePixel = 0
  254. sidebar.Parent = innerFrame
  255. self.Sidebar = sidebar
  256.  
  257. local sidebarCorner = Instance.new("UICorner")
  258. sidebarCorner.CornerRadius = UDim.new(0, 10)
  259. sidebarCorner.Parent = sidebar
  260.  
  261. local sidebarStroke = Instance.new("UIStroke")
  262. sidebarStroke.Color = self.Theme.AccentColor
  263. sidebarStroke.Thickness = 1
  264. sidebarStroke.Parent = sidebar
  265.  
  266. -- Logo Section
  267. local logoFrame = Instance.new("Frame")
  268. logoFrame.Name = "LogoFrame"
  269. logoFrame.Size = UDim2.new(1, -2, 0, 60)
  270. logoFrame.Position = UDim2.new(0, 1, 0, 1)
  271. logoFrame.BackgroundColor3 = Color3.fromRGB(25, 15, 40) -- preserve original
  272. logoFrame.BorderSizePixel = 0
  273. logoFrame.Parent = sidebar
  274.  
  275. local logoCorner = Instance.new("UICorner")
  276. logoCorner.CornerRadius = UDim.new(0, 8)
  277. logoCorner.Parent = logoFrame
  278.  
  279. local logoBottomBorder = Instance.new("Frame")
  280. logoBottomBorder.Size = UDim2.new(1, -20, 0, 1)
  281. logoBottomBorder.Position = UDim2.new(0, 10, 1, -1)
  282. logoBottomBorder.BackgroundColor3 = self.Theme.AccentColor
  283. logoBottomBorder.BorderSizePixel = 0
  284. logoBottomBorder.Parent = logoFrame
  285.  
  286. local logoIcon = Instance.new("TextLabel")
  287. logoIcon.Size = UDim2.new(0, 20, 0, 20)
  288. logoIcon.Position = UDim2.new(0, 15, 0, 15)
  289. logoIcon.BackgroundTransparency = 1
  290. logoIcon.Text = "🌙"
  291. logoIcon.TextColor3 = self.Theme.LogoColor
  292. logoIcon.TextSize = 16
  293. logoIcon.Font = Enum.Font.Gotham
  294. logoIcon.Parent = logoFrame
  295.  
  296. local logoText = Instance.new("TextLabel")
  297. logoText.Size = UDim2.new(0, 120, 0, 20)
  298. logoText.Position = UDim2.new(0, 42, 0, 12)
  299. logoText.BackgroundTransparency = 1
  300. logoText.Text = self.WindowTitle
  301. logoText.TextColor3 = self.Theme.TextPrimary
  302. logoText.TextSize = 15
  303. logoText.TextXAlignment = Enum.TextXAlignment.Left
  304. logoText.Font = Enum.Font.GothamBold
  305. logoText.Parent = logoFrame
  306.  
  307. local logoSubtext = Instance.new("TextLabel")
  308. logoSubtext.Size = UDim2.new(0, 120, 0, 15)
  309. logoSubtext.Position = UDim2.new(0, 42, 0, 32)
  310. logoSubtext.BackgroundTransparency = 1
  311. logoSubtext.Text = "Hollow Purple"
  312. logoSubtext.TextColor3 = self.Theme.LogoSubtextColor
  313. logoSubtext.TextSize = 11
  314. logoSubtext.TextXAlignment = Enum.TextXAlignment.Left
  315. logoSubtext.Font = Enum.Font.Gotham
  316. logoSubtext.Parent = logoFrame
  317.  
  318. -- Navigation Button Container
  319. self.NavButtons = {}
  320. self.CurrentActiveTab = nil
  321. self.NavContainer = sidebar
  322.  
  323. -- Content Area
  324. local contentFrame = Instance.new("Frame")
  325. contentFrame.Name = "ContentFrame"
  326. contentFrame.Size = UDim2.new(1, -182, 1, -2)
  327. contentFrame.Position = UDim2.new(0, 181, 0, 1)
  328. contentFrame.BackgroundColor3 = self.Theme.ContentColor
  329. contentFrame.BorderSizePixel = 0
  330. contentFrame.Parent = innerFrame
  331. self.ContentFrame = contentFrame
  332.  
  333. local contentCorner = Instance.new("UICorner")
  334. contentCorner.CornerRadius = UDim.new(0, 8)
  335. contentCorner.Parent = contentFrame
  336.  
  337. local contentStroke = Instance.new("UIStroke")
  338. contentStroke.Color = self.Theme.AccentColor
  339. contentStroke.Thickness = 1
  340. contentStroke.Parent = contentFrame
  341.  
  342. -- Header
  343. local headerFrame = Instance.new("Frame")
  344. headerFrame.Name = "HeaderFrame"
  345. headerFrame.Size = UDim2.new(1, -2, 0, 55)
  346. headerFrame.Position = UDim2.new(0, 1, 0, 1)
  347. headerFrame.BackgroundColor3 = self.Theme.HeaderColor
  348. headerFrame.BorderSizePixel = 0
  349. headerFrame.Parent = contentFrame
  350. self.HeaderFrame = headerFrame
  351.  
  352. local headerCorner = Instance.new("UICorner")
  353. headerCorner.CornerRadius = UDim.new(0, 6)
  354. headerCorner.Parent = headerFrame
  355.  
  356. local headerBottomBorder = Instance.new("Frame")
  357. headerBottomBorder.Size = UDim2.new(1, -20, 0, 1)
  358. headerBottomBorder.Position = UDim2.new(0, 10, 1, -1)
  359. headerBottomBorder.BackgroundColor3 = self.Theme.AccentColor
  360. headerBottomBorder.BorderSizePixel = 0
  361. headerBottomBorder.Parent = headerFrame
  362.  
  363. local headerTitle = Instance.new("TextLabel")
  364. headerTitle.Name = "HeaderTitle"
  365. headerTitle.Size = UDim2.new(0, 200, 1, 0)
  366. headerTitle.Position = UDim2.new(0, 20, 0, 0)
  367. headerTitle.BackgroundTransparency = 1
  368. headerTitle.Text = ""
  369. headerTitle.TextColor3 = self.Theme.TextPrimary
  370. headerTitle.TextSize = 18
  371. headerTitle.TextXAlignment = Enum.TextXAlignment.Left
  372. headerTitle.Font = Enum.Font.GothamBold
  373. headerTitle.Parent = headerFrame
  374. self.HeaderTitle = headerTitle
  375.  
  376. -- Settings Frame (scrolling)
  377. local settingsFrame = Instance.new("ScrollingFrame")
  378. settingsFrame.Name = "SettingsFrame"
  379. settingsFrame.Size = UDim2.new(1, -4, 1, -57)
  380. settingsFrame.Position = UDim2.new(0, 2, 0, 56)
  381. settingsFrame.BackgroundTransparency = 1
  382. settingsFrame.BorderSizePixel = 0
  383. settingsFrame.ScrollBarThickness = 6
  384. settingsFrame.ScrollBarImageColor3 = self.Theme.ScrollbarColor
  385. settingsFrame.ScrollBarImageTransparency = 0.3
  386. settingsFrame.Parent = contentFrame
  387. self.SettingsFrame = settingsFrame
  388.  
  389. -- Button Container (Minimize, Close)
  390. local buttonContainer = Instance.new("Frame")
  391. buttonContainer.Name = "ButtonContainer"
  392. buttonContainer.Size = UDim2.new(0, 85, 0, 35)
  393. buttonContainer.Position = UDim2.new(1, -90, 0, 15)
  394. buttonContainer.BackgroundTransparency = 1
  395. buttonContainer.BorderSizePixel = 0
  396. buttonContainer.ZIndex = 10
  397. buttonContainer.Parent = mainFrame
  398. self.ButtonContainer = buttonContainer
  399.  
  400. -- Minimize Button
  401. local minimizeButton = Instance.new("TextButton")
  402. minimizeButton.Name = "MinimizeButton"
  403. minimizeButton.Size = UDim2.new(0, 35, 0, 30)
  404. minimizeButton.Position = UDim2.new(0, 0, 0, 0)
  405. minimizeButton.BackgroundColor3 = self.Theme.GlowColors[1]
  406. minimizeButton.BorderSizePixel = 0
  407. minimizeButton.Text = "−"
  408. minimizeButton.TextColor3 = self.Theme.TextPrimary
  409. minimizeButton.TextSize = 18
  410. minimizeButton.Font = Enum.Font.GothamBold
  411. minimizeButton.ZIndex = 11
  412. minimizeButton.Parent = buttonContainer
  413. self.MinimizeButton = minimizeButton
  414.  
  415. local minimizeCorner = Instance.new("UICorner")
  416. minimizeCorner.CornerRadius = UDim.new(0, 6)
  417. minimizeCorner.Parent = minimizeButton
  418.  
  419. local minimizeStroke = Instance.new("UIStroke")
  420. minimizeStroke.Color = self.Theme.GlowColors[2]
  421. minimizeStroke.Thickness = 2
  422. minimizeStroke.Parent = minimizeButton
  423.  
  424. -- Close Button
  425. local closeButton = Instance.new("TextButton")
  426. closeButton.Name = "CloseButton"
  427. closeButton.Size = UDim2.new(0, 35, 0, 30)
  428. closeButton.Position = UDim2.new(0, 40, 0, 0)
  429. closeButton.BackgroundColor3 = Color3.fromRGB(150, 30, 70)
  430. closeButton.BorderSizePixel = 0
  431. closeButton.Text = "×"
  432. closeButton.TextColor3 = self.Theme.TextPrimary
  433. closeButton.TextSize = 20
  434. closeButton.Font = Enum.Font.GothamBold
  435. closeButton.ZIndex = 11
  436. closeButton.Parent = buttonContainer
  437. self.CloseButton = closeButton
  438.  
  439. local closeCorner = Instance.new("UICorner")
  440. closeCorner.CornerRadius = UDim.new(0, 6)
  441. closeCorner.Parent = closeButton
  442.  
  443. local closeStroke = Instance.new("UIStroke")
  444. closeStroke.Color = Color3.fromRGB(220, 100, 150)
  445. closeStroke.Thickness = 2
  446. closeStroke.Parent = closeButton
  447.  
  448. -- Start RGB Animation
  449. self.AnimationConnection = RunService.Heartbeat:Connect(function(deltaTime)
  450. self.Time = self.Time + deltaTime * self.Theme.AnimationSpeed
  451. local t = self.Time % 1
  452. local seq = self.ColorSeq
  453. local currentColor
  454. -- find segment
  455. for i = 1, #seq - 1 do
  456. local c1 = seq[i]
  457. local c2 = seq[i + 1]
  458. if t >= c1.time and t <= c2.time then
  459. local alpha = (t - c1.time) / (c2.time - c1.time)
  460. currentColor = lerpColor(c1.color, c2.color, alpha)
  461. break
  462. end
  463. end
  464. if not currentColor then
  465. local last = seq[#seq]
  466. local first = seq[1]
  467. local alpha = (t - last.time) / (1 - last.time)
  468. currentColor = lerpColor(last.color, first.color, alpha)
  469. end
  470. -- Update strokes
  471. self.MainStroke.Color = currentColor
  472. local glowColor1 = lerpColor(currentColor, self.Theme.GlowColors[1], 0.5)
  473. local glowColor2 = lerpColor(currentColor, self.Theme.GlowColors[2], 0.5)
  474. self.GlowStroke1.Color = glowColor1
  475. self.GlowStroke2.Color = glowColor2
  476. -- Breathing effect
  477. local breathe = 1 + math.sin(self.Time * 1.5) * 0.15
  478. self.MainStroke.Thickness = self.Theme.BorderThickness * breathe
  479. self.GlowStroke1.Thickness = self.Theme.GlowThicknesses[1] * breathe
  480. self.GlowStroke2.Thickness = self.Theme.GlowThicknesses[2] * breathe
  481. end)
  482.  
  483. -- Minimize functionality
  484. minimizeButton.MouseEnter:Connect(function()
  485. local hoverTween = TweenService:Create(minimizeButton,
  486. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  487. {BackgroundColor3 = Color3.fromRGB(95, 55, 150), Size = UDim2.new(0, 37, 0, 32)}
  488. )
  489. hoverTween:Play()
  490. end)
  491. minimizeButton.MouseLeave:Connect(function()
  492. local leaveTween = TweenService:Create(minimizeButton,
  493. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  494. {BackgroundColor3 = self.Theme.GlowColors[1], Size = UDim2.new(0, 35, 0, 30)}
  495. )
  496. leaveTween:Play()
  497. end)
  498. minimizeButton.MouseButton1Click:Connect(function()
  499. if not self.IsMinimized then
  500. local minimizeTween = TweenService:Create(self.MainFrame,
  501. TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.In),
  502. {Size = UDim2.new(0, 804, 0, 55)}
  503. )
  504. minimizeTween:Play()
  505. self.InnerFrame.Visible = false
  506. self.IsMinimized = true
  507. minimizeButton.Text = "□"
  508. else
  509. local restoreTween = TweenService:Create(self.MainFrame,
  510. TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
  511. {Size = UDim2.new(0, 804, 0, 504)}
  512. )
  513. restoreTween:Play()
  514. self.InnerFrame.Visible = true
  515. self.IsMinimized = false
  516. minimizeButton.Text = "−"
  517. end
  518. end)
  519.  
  520. -- Close functionality
  521. closeButton.MouseEnter:Connect(function()
  522. local hoverTween = TweenService:Create(closeButton,
  523. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  524. {BackgroundColor3 = Color3.fromRGB(140, 40, 80), Size = UDim2.new(0, 37, 0, 32)}
  525. )
  526. hoverTween:Play()
  527. end)
  528. closeButton.MouseLeave:Connect(function()
  529. local leaveTween = TweenService:Create(closeButton,
  530. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  531. {BackgroundColor3 = Color3.fromRGB(150, 30, 70), Size = UDim2.new(0, 35, 0, 30)}
  532. )
  533. leaveTween:Play()
  534. end)
  535. closeButton.MouseButton1Click:Connect(function()
  536. local closeTween = TweenService:Create(self.MainFrame,
  537. TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.In),
  538. {Size = UDim2.new(0, 0, 0, 0), Position = UDim2.new(0.5, 0, 0.5, 0)}
  539. )
  540. closeTween:Play()
  541. closeTween.Completed:Connect(function()
  542. screenGui:Destroy()
  543. if self.AnimationConnection then
  544. self.AnimationConnection:Disconnect()
  545. end
  546. end)
  547. end)
  548.  
  549. -- Dragging functionality (from button container or logo frame), only when not minimized
  550. local function beginDrag(input)
  551. if input.UserInputType == Enum.UserInputType.MouseButton1 and not self.IsMinimized then
  552. self.Dragging = true
  553. self.DragStart = input.Position
  554. self.StartPos = self.MainFrame.Position
  555. local dragTween = TweenService:Create(self.MainFrame,
  556. TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  557. {Size = UDim2.new(0, 796, 0, 496)}
  558. )
  559. dragTween:Play()
  560. end
  561. end
  562.  
  563. buttonContainer.InputBegan:Connect(beginDrag)
  564. logoFrame.InputBegan:Connect(beginDrag)
  565.  
  566. self.MainFrame.InputChanged:Connect(function(input)
  567. if self.Dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  568. local delta = input.Position - self.DragStart
  569. self.MainFrame.Position = UDim2.new(self.StartPos.X.Scale, self.StartPos.X.Offset + delta.X,
  570. self.StartPos.Y.Scale, self.StartPos.Y.Offset + delta.Y)
  571. end
  572. end)
  573.  
  574. self.MainFrame.InputEnded:Connect(function(input)
  575. if input.UserInputType == Enum.UserInputType.MouseButton1 and self.Dragging then
  576. self.Dragging = false
  577. if not self.IsMinimized then
  578. local releaseTween = TweenService:Create(self.MainFrame,
  579. TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
  580. {Size = UDim2.new(0, 804, 0, 504)}
  581. )
  582. releaseTween:Play()
  583. end
  584. end
  585. end)
  586.  
  587. -- Hover effects for navigation buttons
  588. self.Sidebar.ChildAdded:Connect(function(child)
  589. if child:IsA("TextButton") then
  590. child.MouseEnter:Connect(function()
  591. if self.CurrentActiveTab ~= child.Name then
  592. local hoverTween = TweenService:Create(child,
  593. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  594. {BackgroundColor3 = Color3.fromRGB(30, 18, 45)}
  595. )
  596. hoverTween:Play()
  597. end
  598. end)
  599. child.MouseLeave:Connect(function()
  600. if self.CurrentActiveTab ~= child.Name then
  601. local leaveTween = TweenService:Create(child,
  602. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  603. {BackgroundColor3 = self.Theme.SidebarColor}
  604. )
  605. leaveTween:Play()
  606. end
  607. end)
  608. end
  609. end)
  610.  
  611. return self
  612. end
  613.  
  614. -- Create a new Tab under the Window
  615. function UILibrary:CreateTab(tabName)
  616. assert(self.NavContainer, "UI not initialized properly")
  617. -- Create navigation button
  618. local navButton = Instance.new("TextButton")
  619. navButton.Name = tabName
  620. navButton.Size = UDim2.new(1, -4, 0, 45)
  621. local index = #self.Tabs + 1
  622. navButton.Position = UDim2.new(0, 2, 0, 60 + (index - 1) * 45)
  623. navButton.BackgroundColor3 = (index == 1) and Color3.fromRGB(35, 20, 55) or self.Theme.SidebarColor
  624. navButton.BorderSizePixel = 0
  625. navButton.Text = tabName
  626. navButton.TextColor3 = (index == 1) and self.Theme.Highlight or self.Theme.TextSecondary
  627. navButton.TextSize = 14
  628. navButton.TextXAlignment = Enum.TextXAlignment.Left
  629. navButton.Font = Enum.Font.GothamMedium
  630. navButton.Parent = self.NavContainer
  631.  
  632. local navCorner = Instance.new("UICorner")
  633. navCorner.CornerRadius = UDim.new(0, 6)
  634. navCorner.Parent = navButton
  635.  
  636. if index == 1 then
  637. -- Active indicator for first tab
  638. local activeIndicator = Instance.new("Frame")
  639. activeIndicator.Name = "ActiveIndicator"
  640. activeIndicator.Size = UDim2.new(0, 4, 0, 25)
  641. activeIndicator.Position = UDim2.new(0, -10, 0.5, -12.5)
  642. activeIndicator.BackgroundColor3 = self.Theme.AccentColor
  643. activeIndicator.BorderSizePixel = 0
  644. activeIndicator.Parent = navButton
  645.  
  646. local indicatorCorner = Instance.new("UICorner")
  647. indicatorCorner.CornerRadius = UDim.new(0, 2)
  648. indicatorCorner.Parent = activeIndicator
  649.  
  650. self.CurrentActiveTab = tabName
  651. self.HeaderTitle.Text = tabName
  652. end
  653.  
  654. local textPadding = Instance.new("UIPadding")
  655. textPadding.PaddingLeft = UDim.new(0, 25)
  656. textPadding.Parent = navButton
  657.  
  658. -- Content container for this tab (Frame inside SettingsFrame)
  659. local contentTabFrame = Instance.new("Frame")
  660. contentTabFrame.Name = tabName .. "_Content"
  661. contentTabFrame.Size = UDim2.new(1, 0, 0, 0) -- will automatically adjust by Layouts
  662. contentTabFrame.BackgroundTransparency = 1
  663. contentTabFrame.Parent = self.SettingsFrame
  664.  
  665. -- Layout inside contentTabFrame
  666. local layout = Instance.new("UIListLayout")
  667. layout.Name = "ListLayout"
  668. layout.SortOrder = Enum.SortOrder.LayoutOrder
  669. layout.Padding = UDim.new(0, 10)
  670. layout.Parent = contentTabFrame
  671.  
  672. local padding = Instance.new("UIPadding")
  673. padding.PaddingTop = UDim.new(0, 10)
  674. padding.PaddingLeft = UDim.new(0, 10)
  675. padding.PaddingRight = UDim.new(0, 10)
  676. padding.Parent = contentTabFrame
  677.  
  678. table.insert(self.Tabs, {
  679. Name = tabName,
  680. Button = navButton,
  681. ContentFrame = contentTabFrame,
  682. })
  683.  
  684. -- Navigation button logic
  685. navButton.MouseButton1Click:Connect(function()
  686. if self.CurrentActiveTab == tabName then
  687. return
  688. end
  689.  
  690. -- Reset all nav buttons
  691. for _, tab in ipairs(self.Tabs) do
  692. local btn = tab.Button
  693. btn.BackgroundColor3 = self.Theme.SidebarColor
  694. btn.TextColor3 = self.Theme.TextSecondary
  695. local indicator = btn:FindFirstChild("ActiveIndicator")
  696. if indicator then
  697. local fadeIndicator = TweenService:Create(indicator,
  698. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  699. {BackgroundTransparency = 1}
  700. )
  701. fadeIndicator:Play()
  702. fadeIndicator.Completed:Connect(function()
  703. indicator:Destroy()
  704. end)
  705. end
  706. end
  707.  
  708. -- Activate clicked button
  709. local selectTween = TweenService:Create(navButton,
  710. TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
  711. {BackgroundColor3 = Color3.fromRGB(35, 20, 55), TextColor3 = self.Theme.Highlight}
  712. )
  713. selectTween:Play()
  714.  
  715. local activeIndicator = Instance.new("Frame")
  716. activeIndicator.Name = "ActiveIndicator"
  717. activeIndicator.Size = UDim2.new(0, 4, 0, 0)
  718. activeIndicator.Position = UDim2.new(0, -10, 0.5, 0)
  719. activeIndicator.BackgroundColor3 = self.Theme.AccentColor
  720. activeIndicator.BorderSizePixel = 0
  721. activeIndicator.Parent = navButton
  722.  
  723. local indicatorCorner = Instance.new("UICorner")
  724. indicatorCorner.CornerRadius = UDim.new(0, 2)
  725. indicatorCorner.Parent = activeIndicator
  726.  
  727. local indicatorTween = TweenService:Create(activeIndicator,
  728. TweenInfo.new(0.4, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
  729. {Size = UDim2.new(0, 4, 0, 25), Position = UDim2.new(0, -10, 0.5, -12.5)}
  730. )
  731. indicatorTween:Play()
  732.  
  733. -- Fade header title
  734. local headerFade = TweenService:Create(self.HeaderTitle,
  735. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  736. {TextTransparency = 1}
  737. )
  738. headerFade:Play()
  739. headerFade.Completed:Connect(function()
  740. self.HeaderTitle.Text = tabName
  741. local headerShow = TweenService:Create(self.HeaderTitle,
  742. TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  743. {TextTransparency = 0}
  744. )
  745. headerShow:Play()
  746. end)
  747.  
  748. -- Hide previous content, show new content
  749. for _, tab in ipairs(self.Tabs) do
  750. tab.ContentFrame.Visible = (tab.Name == tabName)
  751. end
  752.  
  753. self.CurrentActiveTab = tabName
  754. end)
  755.  
  756. -- Show only first tab content initially, hide others
  757. for _, tab in ipairs(self.Tabs) do
  758. tab.ContentFrame.Visible = (tab.Name == self.CurrentActiveTab)
  759. end
  760.  
  761. return contentTabFrame
  762. end
  763.  
  764. -- Create a new Section under a given Tab (contentFrame)
  765. function UILibrary:CreateSection(parentFrame, sectionName)
  766. -- Section container
  767. local sectionFrame = Instance.new("Frame")
  768. sectionFrame.Name = sectionName .. "_Section"
  769. sectionFrame.Size = UDim2.new(1, 0, 0, 0) -- automatic height via UIListLayout
  770. sectionFrame.BackgroundTransparency = 1
  771. sectionFrame.Parent = parentFrame
  772.  
  773. -- Label for section (bold)
  774. local label = Instance.new("TextLabel")
  775. label.Name = "SectionLabel"
  776. label.Size = UDim2.new(1, 0, 0, 20)
  777. label.BackgroundTransparency = 1
  778. label.Text = sectionName
  779. label.TextColor3 = self.Theme.Highlight
  780. label.TextSize = 16
  781. label.TextXAlignment = Enum.TextXAlignment.Left
  782. label.Font = Enum.Font.GothamBold
  783. label.Parent = sectionFrame
  784.  
  785. -- Layout for section contents
  786. local layout = Instance.new("UIListLayout")
  787. layout.Name = "SectionLayout"
  788. layout.SortOrder = Enum.SortOrder.LayoutOrder
  789. layout.Padding = UDim.new(0, 5)
  790. layout.Parent = sectionFrame
  791.  
  792. return sectionFrame
  793. end
  794.  
  795. -- COMPONENT FACTORIES
  796. -- All return the created GuiObject and set up callback logic as needed.
  797.  
  798. -- Button: params: parentFrame, text, callback
  799. function UILibrary:CreateButton(parentFrame, text, callback)
  800. local btnFrame = Instance.new("Frame")
  801. btnFrame.Name = text .. "_ButtonFrame"
  802. btnFrame.Size = UDim2.new(1, 0, 0, 35)
  803. btnFrame.BackgroundTransparency = 1
  804. btnFrame.Parent = parentFrame
  805.  
  806. local button = Instance.new("TextButton")
  807. button.Name = text .. "_Button"
  808. button.Size = UDim2.new(1, 0, 1, 0)
  809. button.BackgroundColor3 = Color3.fromRGB(35, 20, 55)
  810. button.BorderSizePixel = 0
  811. button.Text = text
  812. button.TextColor3 = self.Theme.TextPrimary
  813. button.TextSize = 14
  814. button.Font = Enum.Font.GothamMedium
  815. button.Parent = btnFrame
  816.  
  817. local corner = Instance.new("UICorner")
  818. corner.CornerRadius = UDim.new(0, 6)
  819. corner.Parent = button
  820.  
  821. local stroke = Instance.new("UIStroke")
  822. stroke.Color = self.Theme.AccentColor
  823. stroke.Thickness = 1
  824. stroke.Parent = button
  825.  
  826. -- Hover effect
  827. button.MouseEnter:Connect(function()
  828. local hoverTween = TweenService:Create(button,
  829. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  830. {BackgroundColor3 = Color3.fromRGB(45, 25, 65)}
  831. )
  832. hoverTween:Play()
  833. end)
  834. button.MouseLeave:Connect(function()
  835. local leaveTween = TweenService:Create(button,
  836. TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  837. {BackgroundColor3 = Color3.fromRGB(35, 20, 55)}
  838. )
  839. leaveTween:Play()
  840. end)
  841.  
  842. -- Click callback
  843. button.MouseButton1Click:Connect(function()
  844. if callback then
  845. callback()
  846. end
  847. end)
  848.  
  849. return button
  850. end
  851.  
  852. -- Toggle: params: parentFrame, text, defaultState, callback(newState)
  853. function UILibrary:CreateToggle(parentFrame, text, defaultState, callback)
  854. local togFrame = Instance.new("Frame")
  855. togFrame.Name = text .. "_ToggleFrame"
  856. togFrame.Size = UDim2.new(1, 0, 0, 30)
  857. togFrame.BackgroundTransparency = 1
  858. togFrame.Parent = parentFrame
  859.  
  860. local label = Instance.new("TextLabel")
  861. label.Name = text .. "_ToggleLabel"
  862. label.Size = UDim2.new(1, -40, 1, 0)
  863. label.Position = UDim2.new(0, 0, 0, 0)
  864. label.BackgroundTransparency = 1
  865. label.Text = text
  866. label.TextColor3 = self.Theme.TextPrimary
  867. label.TextSize = 14
  868. label.TextXAlignment = Enum.TextXAlignment.Left
  869. label.Font = Enum.Font.Gotham
  870. label.Parent = togFrame
  871.  
  872. local toggleBtn = Instance.new("Frame")
  873. toggleBtn.Name = text .. "_ToggleButton"
  874. toggleBtn.Size = UDim2.new(0, 24, 0, 14)
  875. toggleBtn.Position = UDim2.new(1, -30, 0.5, -7)
  876. toggleBtn.BackgroundColor3 = defaultState and self.Theme.Highlight or Color3.fromRGB(50, 50, 50)
  877. toggleBtn.BorderSizePixel = 0
  878. toggleBtn.Parent = togFrame
  879.  
  880. local toggleCorner = Instance.new("UICorner")
  881. toggleCorner.CornerRadius = UDim.new(0, 6)
  882. toggleCorner.Parent = toggleBtn
  883.  
  884. local toggleCircle = Instance.new("Frame")
  885. toggleCircle.Name = "ToggleCircle"
  886. toggleCircle.Size = UDim2.new(0, 12, 0, 12)
  887. toggleCircle.Position = defaultState and UDim2.new(1, -14, 0.5, -6) or UDim2.new(0, 2, 0.5, -6)
  888. toggleCircle.BackgroundColor3 = self.Theme.TextPrimary
  889. toggleCircle.BorderSizePixel = 0
  890. toggleCircle.Parent = toggleBtn
  891.  
  892. local circleCorner = Instance.new("UICorner")
  893. circleCorner.CornerRadius = UDim.new(0, 6)
  894. circleCorner.Parent = toggleCircle
  895.  
  896. local state = defaultState
  897.  
  898. local function updateToggle()
  899. if state then
  900. toggleBtn.BackgroundColor3 = self.Theme.Highlight
  901. toggleCircle:TweenPosition(UDim2.new(1, -14, 0.5, -6), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2, true)
  902. else
  903. toggleBtn.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  904. toggleCircle:TweenPosition(UDim2.new(0, 2, 0.5, -6), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2, true)
  905. end
  906. if callback then
  907. callback(state)
  908. end
  909. end
  910.  
  911. toggleBtn.InputBegan:Connect(function(input)
  912. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  913. state = not state
  914. updateToggle()
  915. end
  916. end)
  917.  
  918. return toggleBtn, function() return state end, function(v) state = v; updateToggle() end
  919. end
  920.  
  921. -- Slider: params: parentFrame, text, min, max, defaultValue, callback(newValue)
  922. function UILibrary:CreateSlider(parentFrame, text, min, max, defaultValue, callback)
  923. local sliderFrame = Instance.new("Frame")
  924. sliderFrame.Name = text .. "_SliderFrame"
  925. sliderFrame.Size = UDim2.new(1, 0, 0, 40)
  926. sliderFrame.BackgroundTransparency = 1
  927. sliderFrame.Parent = parentFrame
  928.  
  929. local label = Instance.new("TextLabel")
  930. label.Name = text .. "_SliderLabel"
  931. label.Size = UDim2.new(1, -40, 0, 20)
  932. label.Position = UDim2.new(0, 0, 0, 0)
  933. label.BackgroundTransparency = 1
  934. label.Text = text .. ": " .. tostring(defaultValue)
  935. label.TextColor3 = self.Theme.TextPrimary
  936. label.TextSize = 14
  937. label.TextXAlignment = Enum.TextXAlignment.Left
  938. label.Font = Enum.Font.Gotham
  939. label.Parent = sliderFrame
  940.  
  941. local sliderBar = Instance.new("Frame")
  942. sliderBar.Name = text .. "_SliderBar"
  943. sliderBar.Size = UDim2.new(1, -40, 0, 6)
  944. sliderBar.Position = UDim2.new(0, 0, 0, 24)
  945. sliderBar.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  946. sliderBar.BorderSizePixel = 0
  947. sliderBar.Parent = sliderFrame
  948.  
  949. local barCorner = Instance.new("UICorner")
  950. barCorner.CornerRadius = UDim.new(0, 3)
  951. barCorner.Parent = sliderBar
  952.  
  953. local fillBar = Instance.new("Frame")
  954. fillBar.Name = "FillBar"
  955. fillBar.Size = UDim2.new((defaultValue - min) / (max - min), 0, 1, 0)
  956. fillBar.BackgroundColor3 = self.Theme.Highlight
  957. fillBar.BorderSizePixel = 0
  958. fillBar.Parent = sliderBar
  959.  
  960. local fillCorner = Instance.new("UICorner")
  961. fillCorner.CornerRadius = UDim.new(0, 3)
  962. fillCorner.Parent = fillBar
  963.  
  964. local dragging = false
  965.  
  966. local function updateValue(input)
  967. local relativeX = math.clamp((input.Position.X - sliderBar.AbsolutePosition.X) / sliderBar.AbsoluteSize.X, 0, 1)
  968. local newValue = math.floor(min + (max - min) * relativeX + 0.5)
  969. fillBar.Size = UDim2.new(relativeX, 0, 1, 0)
  970. label.Text = text .. ": " .. tostring(newValue)
  971. if callback then
  972. callback(newValue)
  973. end
  974. end
  975.  
  976. sliderBar.InputBegan:Connect(function(input)
  977. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  978. dragging = true
  979. updateValue(input)
  980. end
  981. end)
  982. sliderBar.InputChanged:Connect(function(input)
  983. if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  984. updateValue(input)
  985. end
  986. end)
  987. sliderBar.InputEnded:Connect(function(input)
  988. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  989. dragging = false
  990. end
  991. end)
  992.  
  993. return sliderBar, function() return tonumber(string.match(label.Text, "%d+")) end, function(v)
  994. local relative = (v - min)/(max - min)
  995. fillBar.Size = UDim2.new(math.clamp(relative, 0, 1), 0, 1, 0)
  996. label.Text = text .. ": " .. tostring(v)
  997. if callback then callback(v) end
  998. end
  999. end
  1000.  
  1001. -- Dropdown: params: parentFrame, text, optionsTable (list of strings), callback(selected)
  1002. function UILibrary:CreateDropdown(parentFrame, text, options, callback)
  1003. local ddFrame = Instance.new("Frame")
  1004. ddFrame.Name = text .. "_DropdownFrame"
  1005. ddFrame.Size = UDim2.new(1, 0, 0, 30)
  1006. ddFrame.BackgroundTransparency = 1
  1007. ddFrame.Parent = parentFrame
  1008.  
  1009. local label = Instance.new("TextLabel")
  1010. label.Name = text .. "_DropdownLabel"
  1011. label.Size = UDim2.new(1, -40, 1, 0)
  1012. label.Position = UDim2.new(0, 0, 0, 0)
  1013. label.BackgroundTransparency = 1
  1014. label.Text = text
  1015. label.TextColor3 = self.Theme.TextPrimary
  1016. label.TextSize = 14
  1017. label.TextXAlignment = Enum.TextXAlignment.Left
  1018. label.Font = Enum.Font.Gotham
  1019. label.Parent = ddFrame
  1020.  
  1021. local arrow = Instance.new("TextLabel")
  1022. arrow.Name = "Arrow"
  1023. arrow.Size = UDim2.new(0, 20, 0, 20)
  1024. arrow.Position = UDim2.new(1, -20, 0.5, -10)
  1025. arrow.BackgroundTransparency = 1
  1026. arrow.Text = "▼"
  1027. arrow.TextColor3 = self.Theme.TextPrimary
  1028. arrow.TextSize = 14
  1029. arrow.Font = Enum.Font.Gotham
  1030. arrow.Parent = ddFrame
  1031.  
  1032. local open = false
  1033. local currentSelection = nil
  1034.  
  1035. local optionsFrame = Instance.new("Frame")
  1036. optionsFrame.Name = "OptionsFrame"
  1037. optionsFrame.Size = UDim2.new(1, 0, 0, 0)
  1038. optionsFrame.Position = UDim2.new(0, 0, 1, 0)
  1039. optionsFrame.BackgroundColor3 = Color3.fromRGB(35, 20, 55)
  1040. optionsFrame.BorderSizePixel = 0
  1041. optionsFrame.ClipsDescendants = true
  1042. optionsFrame.Parent = ddFrame
  1043.  
  1044. local frameCorner = Instance.new("UICorner")
  1045. frameCorner.CornerRadius = UDim.new(0, 6)
  1046. frameCorner.Parent = optionsFrame
  1047.  
  1048. local uiList = Instance.new("UIListLayout")
  1049. uiList.Name = "OptionsList"
  1050. uiList.SortOrder = Enum.SortOrder.LayoutOrder
  1051. uiList.Padding = UDim.new(0, 2)
  1052. uiList.Parent = optionsFrame
  1053.  
  1054. local padding = Instance.new("UIPadding")
  1055. padding.PaddingTop = UDim.new(0, 5)
  1056. padding.PaddingBottom = UDim.new(0, 5)
  1057. padding.PaddingLeft = UDim.new(0, 5)
  1058. padding.PaddingRight = UDim.new(0, 5)
  1059. padding.Parent = optionsFrame
  1060.  
  1061. -- Populate options
  1062. for _, opt in ipairs(options) do
  1063. local optBtn = Instance.new("TextButton")
  1064. optBtn.Name = opt .. "_Option"
  1065. optBtn.Size = UDim2.new(1, 0, 0, 25)
  1066. optBtn.BackgroundColor3 = Color3.fromRGB(25, 15, 40)
  1067. optBtn.BorderSizePixel = 0
  1068. optBtn.Text = opt
  1069. optBtn.TextColor3 = self.Theme.TextPrimary
  1070. optBtn.TextSize = 14
  1071. optBtn.TextXAlignment = Enum.TextXAlignment.Left
  1072. optBtn.Font = Enum.Font.Gotham
  1073. optBtn.Parent = optionsFrame
  1074.  
  1075. local optCorner = Instance.new("UICorner")
  1076. optCorner.CornerRadius = UDim.new(0, 4)
  1077. optCorner.Parent = optBtn
  1078.  
  1079. optBtn.MouseEnter:Connect(function()
  1080. optBtn.BackgroundColor3 = Color3.fromRGB(35, 20, 55)
  1081. end)
  1082. optBtn.MouseLeave:Connect(function()
  1083. optBtn.BackgroundColor3 = Color3.fromRGB(25, 15, 40)
  1084. end)
  1085. optBtn.MouseButton1Click:Connect(function()
  1086. label.Text = text .. ": " .. opt
  1087. currentSelection = opt
  1088. -- collapse
  1089. open = false
  1090. optionsFrame:TweenSize(UDim2.new(1, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2, true)
  1091. if callback then
  1092. callback(opt)
  1093. end
  1094. end)
  1095. end
  1096.  
  1097. -- Toggle dropdown on click
  1098. ddFrame.InputBegan:Connect(function(input)
  1099. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  1100. open = not open
  1101. if open then
  1102. local totalHeight = #options * 27 + 5
  1103. optionsFrame:TweenSize(UDim2.new(1, 0, 0, totalHeight), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2, true)
  1104. else
  1105. optionsFrame:TweenSize(UDim2.new(1, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2, true)
  1106. end
  1107. end
  1108. end)
  1109.  
  1110. return label, function() return currentSelection end, function(v)
  1111. if table.find(options, v) then
  1112. label.Text = text .. ": " .. v
  1113. currentSelection = v
  1114. if callback then callback(v) end
  1115. end
  1116. end
  1117. end
  1118.  
  1119. -- TextBox: params: parentFrame, placeholderText, defaultText, callback(enteredText)
  1120. function UILibrary:CreateTextBox(parentFrame, placeholder, defaultText, callback)
  1121. local tbFrame = Instance.new("Frame")
  1122. tbFrame.Name = "TextBoxFrame"
  1123. tbFrame.Size = UDim2.new(1, 0, 0, 30)
  1124. tbFrame.BackgroundTransparency = 1
  1125. tbFrame.Parent = parentFrame
  1126.  
  1127. local textBox = Instance.new("TextBox")
  1128. textBox.Name = "TextBox"
  1129. textBox.Size = UDim2.new(1, 0, 1, 0)
  1130. textBox.BackgroundColor3 = Color3.fromRGB(25, 15, 40)
  1131. textBox.BorderSizePixel = 0
  1132. textBox.PlaceholderText = placeholder or ""
  1133. textBox.Text = defaultText or ""
  1134. textBox.TextColor3 = self.Theme.TextPrimary
  1135. textBox.TextSize = 14
  1136. textBox.Font = Enum.Font.Gotham
  1137. textBox.ClearTextOnFocus = false
  1138. textBox.Parent = tbFrame
  1139.  
  1140. local corner = Instance.new("UICorner")
  1141. corner.CornerRadius = UDim.new(0, 6)
  1142. corner.Parent = textBox
  1143.  
  1144. local stroke = Instance.new("UIStroke")
  1145. stroke.Color = self.Theme.AccentColor
  1146. stroke.Thickness = 1
  1147. stroke.Parent = textBox
  1148.  
  1149. textBox.FocusLost:Connect(function(enterPressed)
  1150. if enterPressed and callback then
  1151. callback(textBox.Text)
  1152. end
  1153. end)
  1154.  
  1155. return textBox, function() return textBox.Text end, function(v) textBox.Text = v end
  1156. end
  1157.  
  1158. -- ColorPicker: params: parentFrame, defaultColor3, callback(newColor3)
  1159. function UILibrary:CreateColorPicker(parentFrame, defaultColor, callback)
  1160. -- For simplicity, implement a basic RGB sliders popup
  1161. local cpFrame = Instance.new("Frame")
  1162. cpFrame.Name = "ColorPickerFrame"
  1163. cpFrame.Size = UDim2.new(1, 0, 0, 30)
  1164. cpFrame.BackgroundTransparency = 1
  1165. cpFrame.Parent = parentFrame
  1166.  
  1167. local preview = Instance.new("Frame")
  1168. preview.Name = "ColorPreview"
  1169. preview.Size = UDim2.new(0, 30, 0, 30)
  1170. preview.Position = UDim2.new(1, -30, 0, 0)
  1171. preview.BackgroundColor3 = defaultColor or Color3.new(1, 1, 1)
  1172. preview.BorderSizePixel = 0
  1173. preview.Parent = cpFrame
  1174.  
  1175. local previewCorner = Instance.new("UICorner")
  1176. previewCorner.CornerRadius = UDim.new(0, 4)
  1177. previewCorner.Parent = preview
  1178.  
  1179. local cpButton = Instance.new("TextButton")
  1180. cpButton.Name = "OpenColorPicker"
  1181. cpButton.Size = UDim2.new(1, -40, 1, 0)
  1182. cpButton.BackgroundColor3 = Color3.fromRGB(25, 15, 40)
  1183. cpButton.BorderSizePixel = 0
  1184. cpButton.Text = "Select Color"
  1185. cpButton.TextColor3 = self.Theme.TextPrimary
  1186. cpButton.TextSize = 14
  1187. cpButton.Font = Enum.Font.Gotham
  1188. cpButton.Parent = cpFrame
  1189.  
  1190. local buttonCorner = Instance.new("UICorner")
  1191. buttonCorner.CornerRadius = UDim.new(0, 6)
  1192. buttonCorner.Parent = cpButton
  1193.  
  1194. local buttonStroke = Instance.new("UIStroke")
  1195. buttonStroke.Color = self.Theme.AccentColor
  1196. buttonStroke.Thickness = 1
  1197. buttonStroke.Parent = cpButton
  1198.  
  1199. -- Popup Frame (hidden by default)
  1200. local popup = Instance.new("Frame")
  1201. popup.Name = "ColorPopup"
  1202. popup.Size = UDim2.new(0, 200, 0, 160)
  1203. popup.Position = UDim2.new(0.5, -100, 0.5, -80)
  1204. popup.BackgroundColor3 = self.Theme.InnerBackgroundColor
  1205. popup.BorderSizePixel = 0
  1206. popup.Visible = false
  1207. popup.ZIndex = 50
  1208. popup.Parent = cpFrame
  1209.  
  1210. local popupCorner = Instance.new("UICorner")
  1211. popupCorner.CornerRadius = UDim.new(0, 8)
  1212. popupCorner.Parent = popup
  1213.  
  1214. local popupStroke = Instance.new("UIStroke")
  1215. popupStroke.Color = self.Theme.AccentColor
  1216. popupStroke.Thickness = 1
  1217. popupStroke.Parent = popup
  1218.  
  1219. -- Title
  1220. local title = Instance.new("TextLabel")
  1221. title.Name = "ColorPickerTitle"
  1222. title.Size = UDim2.new(1, 0, 0, 20)
  1223. title.Position = UDim2.new(0, 0, 0, 0)
  1224. title.BackgroundTransparency = 1
  1225. title.Text = "RGB Sliders"
  1226. title.TextColor3 = self.Theme.TextPrimary
  1227. title.TextSize = 14
  1228. title.Font = Enum.Font.GothamBold
  1229. title.Parent = popup
  1230.  
  1231. -- Slider creation helper
  1232. local function createChannelSlider(name, yPos, default)
  1233. local frame = Instance.new("Frame")
  1234. frame.Name = name .. "_ChannelFrame"
  1235. frame.Size = UDim2.new(1, -20, 0, 30)
  1236. frame.Position = UDim2.new(0, 10, 0, yPos)
  1237. frame.BackgroundTransparency = 1
  1238. frame.Parent = popup
  1239.  
  1240. local label = Instance.new("TextLabel")
  1241. label.Name = name .. "_Label"
  1242. label.Size = UDim2.new(0.3, 0, 1, 0)
  1243. label.BackgroundTransparency = 1
  1244. label.Text = name .. ": "
  1245. label.TextColor3 = self.Theme.TextPrimary
  1246. label.TextSize = 14
  1247. label.Font = Enum.Font.Gotham
  1248. label.Parent = frame
  1249.  
  1250. local valLabel = Instance.new("TextLabel")
  1251. valLabel.Name = name .. "_ValueLabel"
  1252. valLabel.Size = UDim2.new(0.2, 0, 1, 0)
  1253. valLabel.Position = UDim2.new(0.3, 0, 0, 0)
  1254. valLabel.BackgroundTransparency = 1
  1255. valLabel.Text = tostring(default)
  1256. valLabel.TextColor3 = self.Theme.TextPrimary
  1257. valLabel.TextSize = 14
  1258. valLabel.Font = Enum.Font.Gotham
  1259. valLabel.Parent = frame
  1260.  
  1261. local sliderBar = Instance.new("Frame")
  1262. sliderBar.Name = name .. "_SliderBar"
  1263. sliderBar.Size = UDim2.new(0.4, 0, 0, 6)
  1264. sliderBar.Position = UDim2.new(0.55, 0, 0.5, -3)
  1265. sliderBar.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  1266. sliderBar.BorderSizePixel = 0
  1267. sliderBar.Parent = frame
  1268.  
  1269. local corner = Instance.new("UICorner")
  1270. corner.CornerRadius = UDim.new(0, 3)
  1271. corner.Parent = sliderBar
  1272.  
  1273. local fill = Instance.new("Frame")
  1274. fill.Name = "Fill"
  1275. fill.Size = UDim2.new(default / 255, 0, 1, 0)
  1276. fill.BackgroundColor3 = self.Theme.Highlight
  1277. fill.BorderSizePixel = 0
  1278. fill.Parent = sliderBar
  1279.  
  1280. local fillCorner = Instance.new("UICorner")
  1281. fillCorner.CornerRadius = UDim.new(0, 3)
  1282. fillCorner.Parent = fill
  1283.  
  1284. local dragging = false
  1285.  
  1286. local function updateChannel(input)
  1287. local relX = math.clamp((input.Position.X - sliderBar.AbsolutePosition.X) / sliderBar.AbsoluteSize.X, 0, 1)
  1288. local newVal = math.floor(relX * 255 + 0.5)
  1289. fill.Size = UDim2.new(relX, 0, 1, 0)
  1290. valLabel.Text = tostring(newVal)
  1291. return newVal
  1292. end
  1293.  
  1294. sliderBar.InputBegan:Connect(function(input)
  1295. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  1296. dragging = true
  1297. local v = updateChannel(input)
  1298. return v
  1299. end
  1300. end)
  1301. sliderBar.InputChanged:Connect(function(input)
  1302. if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  1303. local v = updateChannel(input)
  1304. return v
  1305. end
  1306. end)
  1307. sliderBar.InputEnded:Connect(function(input)
  1308. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  1309. dragging = false
  1310. end
  1311. end)
  1312.  
  1313. return {
  1314. Update = function(val)
  1315. local rel = math.clamp(val / 255, 0, 1)
  1316. fill.Size = UDim2.new(rel, 0, 1, 0)
  1317. valLabel.Text = tostring(val)
  1318. end,
  1319. Get = function()
  1320. return tonumber(valLabel.Text)
  1321. end
  1322. }
  1323. end
  1324.  
  1325. -- Create R, G, B sliders
  1326. local rSlider = createChannelSlider("R", 25, defaultColor and math.floor(defaultColor.R * 255) or 255)
  1327. local gSlider = createChannelSlider("G", 60, defaultColor and math.floor(defaultColor.G * 255) or 255)
  1328. local bSlider = createChannelSlider("B", 95, defaultColor and math.floor(defaultColor.B * 255) or 255)
  1329.  
  1330. -- Confirm Button
  1331. local confirmBtn = Instance.new("TextButton")
  1332. confirmBtn.Name = "ColorConfirm"
  1333. confirmBtn.Size = UDim2.new(0.5, 0, 0, 25)
  1334. confirmBtn.Position = UDim2.new(0.25, 0, 1, -30)
  1335. confirmBtn.BackgroundColor3 = Color3.fromRGB(35, 20, 55)
  1336. confirmBtn.BorderSizePixel = 0
  1337. confirmBtn.Text = "Confirm"
  1338. confirmBtn.TextColor3 = self.Theme.TextPrimary
  1339. confirmBtn.TextSize = 14
  1340. confirmBtn.Font = Enum.Font.GothamBold
  1341. confirmBtn.Parent = popup
  1342.  
  1343. local confirmCorner = Instance.new("UICorner")
  1344. confirmCorner.CornerRadius = UDim.new(0, 6)
  1345. confirmCorner.Parent = confirmBtn
  1346.  
  1347. local confirmStroke = Instance.new("UIStroke")
  1348. confirmStroke.Color = self.Theme.AccentColor
  1349. confirmStroke.Thickness = 1
  1350. confirmStroke.Parent = confirmBtn
  1351.  
  1352. local currentColor = defaultColor or Color3.new(1, 1, 1)
  1353.  
  1354. local function applyColor()
  1355. local r = rSlider.Get()
  1356. local g = gSlider.Get()
  1357. local b = bSlider.Get()
  1358. currentColor = Color3.fromRGB(r, g, b)
  1359. preview.BackgroundColor3 = currentColor
  1360. if callback then
  1361. callback(currentColor)
  1362. end
  1363. end
  1364.  
  1365. confirmBtn.MouseButton1Click:Connect(function()
  1366. applyColor()
  1367. popup.Visible = false
  1368. end)
  1369.  
  1370. -- Open/Close popup
  1371. cpButton.MouseButton1Click:Connect(function()
  1372. popup.Visible = not popup.Visible
  1373. if popup.Visible then
  1374. -- Update sliders to reflect current preview
  1375. local cr, cg, cb = preview.BackgroundColor3.R * 255, preview.BackgroundColor3.G * 255, preview.BackgroundColor3.B * 255
  1376. rSlider.Update(math.floor(cr + 0.5))
  1377. gSlider.Update(math.floor(cg + 0.5))
  1378. bSlider.Update(math.floor(cb + 0.5))
  1379. end
  1380. end)
  1381.  
  1382. return preview, function() return currentColor end, function(v)
  1383. if typeof(v) == "Color3" then
  1384. currentColor = v
  1385. preview.BackgroundColor3 = v
  1386. end
  1387. end
  1388. end
  1389.  
  1390. -- Keybind: params: parentFrame, text, defaultKey(Enum.KeyCode), callback(newKey)
  1391. function UILibrary:CreateKeybind(parentFrame, text, defaultKey, callback)
  1392. local kbFrame = Instance.new("Frame")
  1393. kbFrame.Name = text .. "_KeybindFrame"
  1394. kbFrame.Size = UDim2.new(1, 0, 0, 30)
  1395. kbFrame.BackgroundTransparency = 1
  1396. kbFrame.Parent = parentFrame
  1397.  
  1398. local label = Instance.new("TextLabel")
  1399. label.Name = text .. "_KeyLabel"
  1400. label.Size = UDim2.new(0.6, 0, 1, 0)
  1401. label.Position = UDim2.new(0, 0, 0, 0)
  1402. label.BackgroundTransparency = 1
  1403. label.Text = text
  1404. label.TextColor3 = self.Theme.TextPrimary
  1405. label.TextSize = 14
  1406. label.TextXAlignment = Enum.TextXAlignment.Left
  1407. label.Font = Enum.Font.Gotham
  1408. label.Parent = kbFrame
  1409.  
  1410. local keyButton = Instance.new("TextButton")
  1411. keyButton.Name = text .. "_KeyButton"
  1412. keyButton.Size = UDim2.new(0.4, -10, 1, 0)
  1413. keyButton.Position = UDim2.new(0.6, 10, 0, 0)
  1414. keyButton.BackgroundColor3 = Color3.fromRGB(25, 15, 40)
  1415. keyButton.BorderSizePixel = 0
  1416. keyButton.Text = defaultKey.Name
  1417. keyButton.TextColor3 = self.Theme.TextPrimary
  1418. keyButton.TextSize = 14
  1419. keyButton.Font = Enum.Font.Gotham
  1420. keyButton.Parent = kbFrame
  1421.  
  1422. local corner = Instance.new("UICorner")
  1423. corner.CornerRadius = UDim.new(0, 6)
  1424. corner.Parent = keyButton
  1425.  
  1426. local stroke = Instance.new("UIStroke")
  1427. stroke.Color = self.Theme.AccentColor
  1428. stroke.Thickness = 1
  1429. stroke.Parent = keyButton
  1430.  
  1431. local listening = false
  1432. local boundKey = defaultKey
  1433.  
  1434. keyButton.MouseButton1Click:Connect(function()
  1435. if not listening then
  1436. listening = true
  1437. keyButton.Text = "Press any key..."
  1438. local conn = game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
  1439. if not gameProcessed and input.UserInputType == Enum.UserInputType.Keyboard then
  1440. boundKey = input.KeyCode
  1441. keyButton.Text = boundKey.Name
  1442. listening = false
  1443. conn:Disconnect()
  1444. if callback then
  1445. callback(boundKey)
  1446. end
  1447. end
  1448. end)
  1449. end
  1450. end)
  1451.  
  1452. return keyButton, function() return boundKey end, function(v)
  1453. if typeof(v) == "EnumItem" and v.EnumType == Enum.KeyCode then
  1454. boundKey = v
  1455. keyButton.Text = v.Name
  1456. end
  1457. end
  1458. end
  1459.  
  1460. -- Label: static text
  1461. function UILibrary:CreateLabel(parentFrame, text)
  1462. local lbl = Instance.new("TextLabel")
  1463. lbl.Name = text .. "_Label"
  1464. lbl.Size = UDim2.new(1, 0, 0, 20)
  1465. lbl.BackgroundTransparency = 1
  1466. lbl.Text = text
  1467. lbl.TextColor3 = self.Theme.TextPrimary
  1468. lbl.TextSize = 14
  1469. lbl.TextXAlignment = Enum.TextXAlignment.Left
  1470. lbl.Font = Enum.Font.Gotham
  1471. lbl.Parent = parentFrame
  1472. return lbl
  1473. end
  1474.  
  1475. -- Paragraph: multi-line text
  1476. function UILibrary:CreateParagraph(parentFrame, text)
  1477. local pg = Instance.new("TextLabel")
  1478. pg.Name = "Paragraph"
  1479. pg.Size = UDim2.new(1, 0, 0, 0)
  1480. pg.BackgroundTransparency = 1
  1481. pg.Text = text
  1482. pg.TextColor3 = self.Theme.TextPrimary
  1483. pg.TextSize = 14
  1484. pg.TextXAlignment = Enum.TextXAlignment.Left
  1485. pg.TextYAlignment = Enum.TextYAlignment.Top
  1486. pg.Font = Enum.Font.Gotham
  1487. pg.TextWrapped = true
  1488. pg.Parent = parentFrame
  1489.  
  1490. -- Adjust height based on text
  1491. pg:GetPropertyChangedSignal("TextBounds"):Connect(function()
  1492. local bounds = pg.TextBounds
  1493. pg.Size = UDim2.new(1, 0, 0, bounds.Y + 10)
  1494. end)
  1495.  
  1496. return pg
  1497. end
  1498.  
  1499. -----------------------------
  1500. -- USAGE EXAMPLE (Full LunarZ UI Implementation)
  1501. -----------------------------
  1502. -- Wait for PlayerGui
  1503. local player = Players.LocalPlayer
  1504. local playerGui = player:WaitForChild("PlayerGui")
  1505.  
  1506. -- Create Window
  1507. local ui = UILibrary.NewWindow(playerGui, "LunarZ Hub", "HollowPurple")
  1508.  
  1509. -- Create Tabs
  1510. local mainTab = ui:CreateTab("Main")
  1511. local statsTab = ui:CreateTab("Stats")
  1512. local cosmeticsTab = ui:CreateTab("Cosmetics")
  1513. local autoTab = ui:CreateTab("Auto Start")
  1514.  
  1515. -- MAIN TAB Sections and Components (example content; replicate original settings)
  1516. -- Example Section: “General”
  1517. local generalSection = ui:CreateSection(mainTab, "General")
  1518. ui:CreateLabel(generalSection, "Welcome to LunarZ Hub!")
  1519. ui:CreateButton(generalSection, "Do Something", function()
  1520. print("Button clicked on Main → General")
  1521. end)
  1522.  
  1523. -- Example Section: “Settings”
  1524. local settingsSection = ui:CreateSection(mainTab, "Settings")
  1525. local toggleBtn, getToggleState, setToggleState = ui:CreateToggle(settingsSection, "Enable Feature", false, function(state)
  1526. print("Feature toggled:", state)
  1527. end)
  1528. local sliderBar, getSliderValue, setSliderValue = ui:CreateSlider(settingsSection, "Volume", 0, 100, 50, function(value)
  1529. print("Slider changed to:", value)
  1530. end)
  1531. local ddLabel, getDropdown, setDropdown = ui:CreateDropdown(settingsSection, "Select Mode", {"Easy", "Normal", "Hard"}, function(selection)
  1532. print("Dropdown selected:", selection)
  1533. end)
  1534. ui:CreateTextBox(settingsSection, "Enter Name", "", function(text)
  1535. print("Text entered:", text)
  1536. end)
  1537. local colorPreview, getColor, setColor = ui:CreateColorPicker(settingsSection, Color3.fromRGB(186, 85, 211), function(color)
  1538. print("Color picked:", color)
  1539. end)
  1540. local keybindBtn, getKeybind, setKeybind = ui:CreateKeybind(settingsSection, "Bind Key", Enum.KeyCode.F, function(key)
  1541. print("Keybind set to:", key.Name)
  1542. end)
  1543.  
  1544. -- STATISTICS TAB
  1545. local statsSection = ui:CreateSection(statsTab, "Player Stats")
  1546. ui:CreateLabel(statsSection, "Kills: 0")
  1547. ui:CreateLabel(statsSection, "Deaths: 0")
  1548. ui:CreateLabel(statsSection, "Playtime: 0m")
  1549.  
  1550. -- COSMETICS TAB
  1551. local cosmeticsSection = ui:CreateSection(cosmeticsTab, "Choose Cosmetic")
  1552. local cosmeticDropdownLabel, getCosmetic, setCosmetic = ui:CreateDropdown(cosmeticsSection, "Skin", {"Default", "Blue", "Gold"}, function(sel)
  1553. print("Cosmetic chosen:", sel)
  1554. end)
  1555. ui:CreateButton(cosmeticsSection, "Apply Cosmetic", function()
  1556. print("Applying cosmetic:", getCosmetic())
  1557. end)
  1558.  
  1559. -- AUTO START TAB
  1560. local autoSection = ui:CreateSection(autoTab, "Auto Actions")
  1561. local autoToggle, getAutoState, setAutoState = ui:CreateToggle(autoSection, "Auto Farm", false, function(s)
  1562. print("Auto Farm toggled:", s)
  1563. end)
  1564.  
  1565. -- Example: Save and Load Config buttons under a “Config” section
  1566. local configSection = ui:CreateSection(mainTab, "Config")
  1567. ui:CreateButton(configSection, "Save Settings", function()
  1568. local state = {
  1569. FeatureEnabled = getToggleState(),
  1570. Volume = getSliderValue(),
  1571. Mode = getDropdown(),
  1572. PlayerName = ui:FindFirstChild("TextBox") and ui:FindFirstChild("TextBox").Text or "",
  1573. ChosenColor = tostring(getColor()),
  1574. BoundKey = tostring(getKeybind())
  1575. }
  1576. ui:SaveConfig("UserSettings", state)
  1577. print("Settings saved.")
  1578. end)
  1579. ui:CreateButton(configSection, "Load Settings", function()
  1580. local loaded = ui:LoadConfig("UserSettings")
  1581. if loaded then
  1582. setToggleState(loaded.FeatureEnabled or false)
  1583. setSliderValue(loaded.Volume or 50)
  1584. setDropdown(loaded.Mode or "Normal")
  1585. -- For TextBox: find it if named, or store reference above for real implementation
  1586. -- setColor: convert string back to Color3 if needed; this example stores tostring(color)
  1587. -- setKeybind: convert string back to Enum.KeyCode using Enum.KeyCode[string]
  1588. print("Settings loaded:", loaded)
  1589. else
  1590. print("No saved settings found.")
  1591. end
  1592. end)
  1593.  
  1594. -- Example: Send test webhook
  1595. local webhookSection = ui:CreateSection(mainTab, "Webhook")
  1596. ui:CreateTextBox(webhookSection, "Enter Webhook URL", "", function(url)
  1597. -- store locally if needed
  1598. end)
  1599. ui:CreateButton(webhookSection, "Send Test Webhook", function()
  1600. local testUrl = "" -- replace with stored URL from above textbox
  1601. if testUrl ~= "" then
  1602. ui:SendWebhook(testUrl, {content = "Test message from LunarZ UI"})
  1603. print("Webhook sent.")
  1604. else
  1605. warn("Webhook URL not provided.")
  1606. end
  1607. end)
  1608.  
  1609. -- The script above reproduces the entire original LunarZ UI using the modular UILibrary.
  1610. -- All animations, colors, and behaviors are preserved exactly as before.
  1611. -- You can organize new features by adding Tabs, Sections, and Components using the functions provided.
  1612. -- To add a new theme, simply insert into UILibrary.Themes with the same structure and call NewWindow with themeName.
  1613.  
  1614.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement