jxuser

NexusLib UI V6

Jul 10th, 2025 (edited)
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 40.88 KB | None | 0 0
  1. --// NexusLib V3.2 by NexusRobloxScripts
  2. --// TO ADD: UI (animated) expands horizontally and vertically(down) when un-colapsing to provide a larger interface, reverses the process when collapsing to title bar. Make the whole UI more rectangular horizontally instead of vertically.
  3. --// TO ADD: Improve UI Animations, transition, color scheme, etc
  4. --// TO ADD: Allow users to modify UI Accent colors and fonts via APi calls like Nex:Font and Nex:Color (RGB code)
  5. --// TO ADD: KeyBinding Function (Nex:addKeybind(Title, toggle title, callback)- This should display (in order): Label for the function, Text box (to take users desired keybind), and a toggle (red/green slider toggle to enable / disable keybind / turn off)
  6.  
  7. local TweenService = game:GetService("TweenService")
  8. local player = game.Players.LocalPlayer
  9. local Players = game:GetService("Players")
  10. local parentGui = game:GetService("CoreGui")
  11. local Lighting = game:GetService("Lighting")
  12. local playerGui = player:WaitForChild("PlayerGui")
  13. local notificationQueue = {}
  14. local activeNotifications = 0
  15. local MAX_NOTIFICATIONS = 3
  16. local activeNotificationFrames = {}
  17. local UIS = game:GetService("UserInputService")
  18. local Nex = {}
  19.  
  20. -- Global variables for accent color and font
  21. local accentColor = Color3.fromRGB(0, 170, 255) -- Default accent color
  22. local uiFont = Enum.Font.Gotham -- Default font
  23. local uiTextSize = 13 -- Default text size
  24.  
  25. -- Flag to check if any API functions were called
  26. local apiCalled = false
  27.  
  28. --// Handle GUI parent fallbacks (e.g., CoreGui not accessible)
  29. pcall(function()
  30.     if not parentGui:IsDescendantOf(game) then
  31.         parentGui = player:WaitForChild("PlayerGui")
  32.     end
  33. end)
  34.  
  35. --// Remove any existing credit popup or library UI
  36. local oldPopup = parentGui:FindFirstChild("CreditPopup")
  37. if oldPopup then oldPopup:Destroy() end
  38.  
  39. local oldLibUI = parentGui:FindFirstChild("NexusLib")
  40. if oldLibUI then oldLibUI:Destroy() end
  41.  
  42.  
  43. -- 🧱 Create reusable rounded corner
  44. local function createRounded(instance, radius)
  45.     local corner = Instance.new("UICorner")
  46.     corner.CornerRadius = UDim.new(0, radius or 6)
  47.     corner.Parent = instance
  48. end
  49.  
  50. --// NOTIFICATION MODULE:
  51. -- Find or fallback for main UI ScreenGui to parent notifications inside it
  52. local ScreenGui = parentGui:FindFirstChild("NexusLib")
  53. if not ScreenGui then
  54.     ScreenGui = player:WaitForChild("PlayerGui"):FindFirstChild("NexusLib")
  55.     if not ScreenGui then
  56.         ScreenGui = Instance.new("ScreenGui")
  57.         ScreenGui.Name = "NexusLib"
  58.         ScreenGui.ResetOnSpawn = false
  59.         ScreenGui.IgnoreGuiInset = true
  60.         ScreenGui.DisplayOrder = 10
  61.         ScreenGui.Parent = player:WaitForChild("PlayerGui")
  62.         print("[Notification] Created fallback NexusLib ScreenGui in PlayerGui")
  63.     end
  64. end
  65.  
  66. -- 📌 Notification container for up to 3 notifications, bottom-centered
  67. local NotificationContainer = Instance.new("Frame")
  68. NotificationContainer.Name = "NotificationContainer"
  69. NotificationContainer.AnchorPoint = Vector2.new(1, 1)  -- bottom-right anchor
  70. NotificationContainer.Position = UDim2.new(1, -15, 1, -15)  -- bottom right with margin offsets
  71. NotificationContainer.Size = UDim2.new(0, 300, 0, 165)  -- size for ~3 notifications
  72. NotificationContainer.BackgroundTransparency = 1
  73. NotificationContainer.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
  74. NotificationContainer.ZIndex = 10
  75. NotificationContainer.ClipsDescendants = false
  76. NotificationContainer.Visible = true
  77. NotificationContainer.Parent = ScreenGui
  78.  
  79. print("[Notification] NotificationContainer created and parented to", NotificationContainer.Parent:GetFullName())
  80.  
  81. -- 🖼️ Type styling helper
  82. local function getTypeStyle(notificationType)
  83.     local icon, color
  84.     if notificationType == "S" then
  85.         icon = "✅"
  86.         color = Color3.fromRGB(0, 200, 100)
  87.     elseif notificationType == "E" then
  88.         icon = "⚠️"
  89.         color = Color3.fromRGB(255, 180, 0)
  90.     else
  91.         icon = "📢"
  92.         color = Color3.fromRGB(0, 170, 255)
  93.     end
  94.     return icon, color
  95. end
  96.  
  97. -- 🔁 Process the notification queue
  98.  
  99. local function processQueue()
  100.     if activeNotifications >= MAX_NOTIFICATIONS then return end
  101.     if #notificationQueue == 0 then return end
  102.  
  103.     local data = table.remove(notificationQueue, 1)
  104.     activeNotifications += 1
  105.  
  106.     local notif = Instance.new("Frame")
  107.     notif.Size = UDim2.new(1, 0, 0, 50)
  108.     notif.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  109.     notif.BorderSizePixel = 0
  110.     notif.BackgroundTransparency = 0
  111.     notif.ClipsDescendants = true
  112.     notif.ZIndex = 11
  113.     notif.Visible = true
  114.     notif.Parent = NotificationContainer
  115.     createRounded(notif, 6)
  116.  
  117.     -- Add new notification at the BOTTOM of active list (end)
  118.     table.insert(activeNotificationFrames, notif)
  119.  
  120.     -- Recalculate positions from top (oldest) to bottom (newest)
  121.     for i, frame in ipairs(activeNotificationFrames) do
  122.         local targetY = -165 + (i - 1) * 55  -- Start at top edge, move down 55 px each
  123.         TweenService:Create(frame, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
  124.             Position = UDim2.new(0, 0, 1, targetY)
  125.         }):Play()
  126.     end
  127.  
  128.     -- Start below container bottom, slide up into place at bottom (newest slot)
  129.     notif.Position = UDim2.new(0, 0, 1, 60)
  130.  
  131.     local icon, strokeColor = getTypeStyle(data.type)
  132.  
  133.     local stroke = Instance.new("UIStroke")
  134.     stroke.Color = strokeColor
  135.     stroke.Thickness = 1
  136.     stroke.Transparency = 0.3
  137.     stroke.Parent = notif
  138.  
  139.     local label = Instance.new("TextLabel")
  140.     label.Text = icon .. "  " .. data.text
  141.     label.Font = Enum.Font.Gotham
  142.     label.TextSize = 14
  143.     label.TextColor3 = Color3.fromRGB(255, 255, 255)
  144.     label.BackgroundTransparency = 1
  145.     label.TextWrapped = true
  146.     label.TextXAlignment = Enum.TextXAlignment.Left
  147.     label.Size = UDim2.new(1, -16, 1, -16)
  148.     label.Position = UDim2.new(0, 8, 0, 4)
  149.     label.ZIndex = 12
  150.     label.Parent = notif
  151.  
  152.     local progress = Instance.new("Frame")
  153.     progress.Size = UDim2.new(1, 0, 0, 3)
  154.     progress.Position = UDim2.new(0, 0, 1, -3)
  155.     progress.BackgroundColor3 = strokeColor
  156.     progress.BorderSizePixel = 0
  157.     progress.ZIndex = 13
  158.     progress.Parent = notif
  159.     createRounded(progress, 3)
  160.  
  161.     local progressTween = TweenService:Create(progress, TweenInfo.new(data.duration, Enum.EasingStyle.Linear), {
  162.         Size = UDim2.new(0, 0, 0, 3)
  163.     })
  164.     progressTween:Play()
  165.  
  166.     task.delay(data.duration, function()
  167.         local fade = TweenService:Create(notif, TweenInfo.new(0.4), {BackgroundTransparency = 1})
  168.         local labelFade = TweenService:Create(label, TweenInfo.new(0.4), {TextTransparency = 1})
  169.         local progressFade = TweenService:Create(progress, TweenInfo.new(0.3), {BackgroundTransparency = 1})
  170.         progressTween:Cancel()
  171.  
  172.         fade:Play()
  173.         labelFade:Play()
  174.         progressFade:Play()
  175.  
  176.         task.wait(0.4)
  177.         notif:Destroy()
  178.         activeNotifications -= 1
  179.  
  180.         -- Remove from list
  181.         for i, frame in ipairs(activeNotificationFrames) do
  182.             if frame == notif then
  183.                 table.remove(activeNotificationFrames, i)
  184.                 break
  185.             end
  186.         end
  187.  
  188.         -- Re-stack remaining from top (oldest) to bottom (newest)
  189.         for i, frame in ipairs(activeNotificationFrames) do
  190.             local targetY = -165 + (i - 1) * 55
  191.             TweenService:Create(frame, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
  192.                 Position = UDim2.new(0, 0, 1, targetY)
  193.             }):Play()
  194.         end
  195.  
  196.         processQueue()
  197.     end)
  198. end
  199.  
  200.  
  201. -- 📣 Main Notify function for Nex
  202. function Nex:Notify(text, duration, notificationType)
  203.     print("[Notification] Adding notification to queue:", text)
  204.     table.insert(notificationQueue, {
  205.         text = tostring(text),
  206.         duration = duration or 5,
  207.         type = notificationType or "D"
  208.     })
  209.     processQueue()
  210. end
  211.  
  212.  
  213. --// Credits
  214.  
  215. --// Blur background
  216. local blur = Instance.new("BlurEffect")
  217. blur.Size = 0
  218. blur.Name = "NexCreditBlur"
  219. blur.Parent = Lighting
  220. TweenService:Create(blur, TweenInfo.new(0.5), {Size = 12}):Play()
  221.  
  222. --// GUI container
  223. local gui = Instance.new("ScreenGui")
  224. gui.Name = "CreditPopup"
  225. gui.IgnoreGuiInset = true
  226. gui.ResetOnSpawn = false
  227. gui.Parent = parentGui
  228.  
  229. --// Main popup frame
  230. local popup = Instance.new("Frame")
  231. popup.Size = UDim2.new(0, 280, 0, 80)
  232. popup.Position = UDim2.new(0.5, 0, 0.5, 0)
  233. popup.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
  234. popup.BackgroundTransparency = 1
  235. popup.BorderSizePixel = 0
  236. popup.AnchorPoint = Vector2.new(0.5, 0.5)
  237. popup.Parent = gui
  238.  
  239. -- Rounded corners and stroke
  240. Instance.new("UICorner", popup).CornerRadius = UDim.new(0, 8)
  241. local stroke = Instance.new("UIStroke", popup)
  242. stroke.Color = Color3.fromRGB(0, 170, 255)
  243. stroke.Thickness = 2
  244. stroke.Transparency = 0.4
  245.  
  246. --// Icon image
  247. local icon = Instance.new("ImageLabel")
  248. icon.Size = UDim2.new(0, 40, 0, 40)
  249. icon.Position = UDim2.new(0, 10, 0, 20)
  250. icon.BackgroundTransparency = 1
  251. icon.Image = "rbxassetid://6031075938"
  252. icon.ScaleType = Enum.ScaleType.Fit
  253. icon.ClipsDescendants = true
  254. icon.ImageTransparency = 1
  255. icon.Parent = popup
  256. Instance.new("UIAspectRatioConstraint", icon).AspectRatio = 1
  257.  
  258. --// Text: Title
  259. local mainLabel = Instance.new("TextLabel")
  260. mainLabel.Position = UDim2.new(0, 60, 0, 12)
  261. mainLabel.Size = UDim2.new(1, -70, 0, 24)
  262. mainLabel.BackgroundTransparency = 1
  263. mainLabel.Text = "NexusLib UI"
  264. mainLabel.Font = Enum.Font.GothamBold
  265. mainLabel.TextSize = 16
  266. mainLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  267. mainLabel.TextXAlignment = Enum.TextXAlignment.Left
  268. mainLabel.Parent = popup
  269.  
  270. --// Text: Link
  271. local socialLink = Instance.new("TextButton")
  272. socialLink.Position = UDim2.new(0, 60, 0, 40)
  273. socialLink.Size = UDim2.new(1, -70, 0, 18)
  274. socialLink.BackgroundTransparency = 1
  275. socialLink.Text = "@NexusRobloxScripts"
  276. socialLink.Font = Enum.Font.Gotham
  277. socialLink.TextSize = 13
  278. socialLink.TextColor3 = Color3.fromRGB(0, 170, 255)
  279. socialLink.TextXAlignment = Enum.TextXAlignment.Left
  280. socialLink.AutoButtonColor = false
  281. socialLink.Parent = popup
  282.  
  283. -- Added functionality to copy the link and notify
  284. local url = "https://youtube.com/NexusRobloxScripts"
  285.  
  286. socialLink.MouseButton1Click:Connect(function()
  287.     -- Copy to clipboard (works on executors like Delta)
  288.     if setclipboard then
  289.         setclipboard(url)
  290.         Nex:Notify("YouTube Link Copied!", 3, "S")
  291.     end
  292. end)
  293.  
  294.  
  295. --// Loading bar background
  296. local loadingBarBg = Instance.new("Frame")
  297. loadingBarBg.Size = UDim2.new(0, 180, 0, 12) -- made narrower
  298. loadingBarBg.Position = UDim2.new(0, 60, 0, 65) -- same position
  299. loadingBarBg.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  300. loadingBarBg.BorderSizePixel = 0
  301. loadingBarBg.AnchorPoint = Vector2.new(0, 0)
  302. loadingBarBg.Parent = popup
  303. Instance.new("UICorner", loadingBarBg).CornerRadius = UDim.new(0, 6)
  304.  
  305. --// Loading bar fill
  306. local loadingBarFill = Instance.new("Frame")
  307. loadingBarFill.Size = UDim2.new(0, 0, 1, 0) -- starts empty
  308. loadingBarFill.Position = UDim2.new(0, 0, 0, 0)
  309. loadingBarFill.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
  310. loadingBarFill.BorderSizePixel = 0
  311. loadingBarFill.Parent = loadingBarBg
  312. Instance.new("UICorner", loadingBarFill).CornerRadius = UDim.new(0, 6)
  313.  
  314. --// Percentage label
  315. local loadingPercent = Instance.new("TextLabel")
  316. loadingPercent.Size = UDim2.new(0, 40, 0, 12) -- slightly smaller width
  317. loadingPercent.Position = UDim2.new(1, -45, 0, 0) -- moved left inside the bar's right edge
  318. loadingPercent.BackgroundTransparency = 1
  319. loadingPercent.Text = "0%"
  320. loadingPercent.Font = Enum.Font.GothamBold
  321. loadingPercent.TextSize = 12
  322. loadingPercent.TextColor3 = Color3.fromRGB(255, 255, 255)
  323. loadingPercent.TextXAlignment = Enum.TextXAlignment.Right -- right-align to fit nicely
  324. loadingPercent.Parent = loadingBarBg
  325.  
  326.  
  327. --// Fade in popup
  328. TweenService:Create(popup, TweenInfo.new(0.5), {BackgroundTransparency = 0}):Play()
  329. TweenService:Create(icon, TweenInfo.new(0.5), {ImageTransparency = 0}):Play()
  330.  
  331. --// Update loading bar over time instead of static wait
  332. local displayTime = 3 -- Reduced display time for faster load
  333. local updateInterval = 0.05
  334.  
  335. for elapsed = 0, displayTime, updateInterval do
  336.     local progress = elapsed / displayTime
  337.     local percent = math.floor(progress * 100)
  338.     loadingBarFill.Size = UDim2.new(progress, 0, 1, 0)
  339.     loadingPercent.Text = percent .. "%"
  340.     task.wait(updateInterval)
  341. end
  342.  
  343. -- Ensure fully filled at end
  344. loadingBarFill.Size = UDim2.new(1, 0, 1, 0)
  345. loadingPercent.Text = "100%"
  346.  
  347. --// Fade out popup
  348. TweenService:Create(popup, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
  349. TweenService:Create(icon, TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
  350. TweenService:Create(blur, TweenInfo.new(0.5), {Size = 0}):Play()
  351.  
  352. --// Cleanup after fade
  353. task.delay(0.5, function()
  354.     blur:Destroy()
  355.     gui:Destroy()
  356. end)
  357.  
  358.  
  359.  
  360.  
  361. -- START OF THE UI MAIN WINDOW, SEE COMMENTS FOR INFO!!!!
  362. local isCollapsed = true
  363. local dragging, dragStart, startPos
  364.  
  365. -- UI Container
  366. local ScreenGui = Instance.new("ScreenGui")
  367. ScreenGui.Name = "NexusLib"
  368. ScreenGui.ResetOnSpawn = false
  369. ScreenGui.IgnoreGuiInset = true
  370. ScreenGui.Parent = parentGui
  371.  
  372. -- Main Window
  373. local MainFrame = Instance.new("Frame")
  374. MainFrame.Name = "MainFrame"
  375. MainFrame.Position = UDim2.new(0.3, 0, 0.3, 0)
  376. MainFrame.Size = UDim2.new(0, 250, 0, 25)  -- collapsed size (more rectangular horizontally)
  377. MainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
  378. MainFrame.BorderSizePixel = 0
  379. MainFrame.Active = true
  380. MainFrame.Parent = ScreenGui
  381. createRounded(MainFrame, 6)  -- slightly smaller corner radius
  382.  
  383. local UIStroke = Instance.new("UIStroke", MainFrame)
  384. UIStroke.Thickness = 1.5
  385. UIStroke.Color = accentColor
  386. UIStroke.Transparency = 0.3
  387.  
  388. -- Title Bar
  389. local TitleBar = Instance.new("TextButton")
  390. TitleBar.Text = " UI Menu "
  391. TitleBar.Font = uiFont
  392. TitleBar.TextSize = 14  -- smaller font size
  393. TitleBar.Size = UDim2.new(1, 0, 0, 25)  -- shorter height
  394. TitleBar.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  395. TitleBar.TextColor3 = Color3.fromRGB(255, 255, 255)
  396. TitleBar.BorderSizePixel = 0
  397. TitleBar.AutoButtonColor = false
  398. TitleBar.Parent = MainFrame
  399. createRounded(TitleBar, 6)
  400.  
  401. -- Collapse Button
  402. local CollapseButton = Instance.new("TextButton")
  403. CollapseButton.Size = UDim2.new(0, 25, 1, 0)
  404. CollapseButton.Position = UDim2.new(1, -25, 0, 0)
  405. CollapseButton.Text = "+"
  406. CollapseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  407. CollapseButton.Font = uiFont
  408. CollapseButton.TextSize = 14
  409. CollapseButton.BackgroundTransparency = 1
  410. CollapseButton.Parent = TitleBar
  411.  
  412. -- Add icon to TitleBar
  413. local titleIcon = Instance.new("ImageLabel")
  414. titleIcon.Size = UDim2.new(0, 20, 0, 20)  -- small square icon
  415. titleIcon.Position = UDim2.new(0, 5, 0.5, -10)  -- left side with vertical center alignment
  416. titleIcon.BackgroundTransparency = 1
  417. titleIcon.Image = "rbxassetid://6031075938"  -- same asset ID as your popup icon
  418. titleIcon.ScaleType = Enum.ScaleType.Fit
  419. titleIcon.Parent = TitleBar
  420.  
  421. -- Container (scrolling frame for controls)
  422. local Container = Instance.new("ScrollingFrame")
  423. Container.Size = UDim2.new(1, -8, 1, -32)
  424. Container.Position = UDim2.new(0, 4, 0, 29)
  425. Container.CanvasSize = UDim2.new(0, 0, 0, 0)
  426. Container.ScrollBarThickness = 5
  427. Container.AutomaticCanvasSize = Enum.AutomaticSize.Y
  428. Container.BackgroundTransparency = 1
  429. Container.Visible = false
  430. Container.Parent = MainFrame
  431.  
  432. local UIListLayout = Instance.new("UIListLayout", Container)
  433. UIListLayout.Padding = UDim.new(0, 5)  -- smaller padding
  434. UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
  435.  
  436. -- Collapse toggle logic
  437. CollapseButton.MouseButton1Click:Connect(function()
  438.     isCollapsed = not isCollapsed
  439.     CollapseButton.Text = isCollapsed and "+" or "–"
  440.  
  441.     local targetSizeX = isCollapsed and 250 or 350 -- Expanded width
  442.     local targetSizeY = isCollapsed and 25 or 320 -- Expanded height (downwards)
  443.  
  444.     local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out)
  445.  
  446.     TweenService:Create(MainFrame, tweenInfo, {
  447.         Size = UDim2.new(0, targetSizeX, 0, targetSizeY)
  448.     }):Play()
  449.  
  450.     -- Fade in/out container (optional, for smoother transition)
  451.     if not isCollapsed then
  452.         Container.Visible = true
  453.         TweenService:Create(Container, TweenInfo.new(0.2, Enum.EasingStyle.Quad), {BackgroundTransparency = 0, ScrollingCanvasBackgroundColor = Color3.fromRGB(20,20,20)}):Play()
  454.     else
  455.         TweenService:Create(Container, TweenInfo.new(0.2, Enum.EasingStyle.Quad), {BackgroundTransparency = 1, ScrollingCanvasBackgroundColor = Color3.fromRGB(20,20,20)}):Play()
  456.         task.wait(0.2) -- Wait for fade out before hiding
  457.         Container.Visible = false
  458.     end
  459. end)
  460.  
  461. -- Draggable logic (exclude collapse button area)
  462. TitleBar.InputBegan:Connect(function(input)
  463.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  464.         if UIS:GetFocusedTextBox() == nil then
  465.             local mousePos = input.Position
  466.             local cbPos = CollapseButton.AbsolutePosition
  467.             local cbSize = CollapseButton.AbsoluteSize
  468.             if not (mousePos.X >= cbPos.X and mousePos.X <= cbPos.X + cbSize.X) then
  469.                 dragging = true
  470.                 dragStart = input.Position
  471.                 startPos = MainFrame.Position
  472.                 input.Changed:Connect(function()
  473.                     if input.UserInputState == Enum.UserInputState.End then
  474.                         dragging = false
  475.                     end
  476.                 end)
  477.             end
  478.         end
  479.     end
  480. end)
  481.  
  482. UIS.InputChanged:Connect(function(input)
  483.     if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  484.         local delta = input.Position - dragStart
  485.         MainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  486.     end
  487. end)
  488.  
  489. -- Function to apply font and color to all existing and future UI elements
  490. local function applyUITheme()
  491.     -- Apply to MainFrame stroke
  492.     UIStroke.Color = accentColor
  493.  
  494.     -- Apply to TitleBar
  495.     TitleBar.Font = uiFont
  496.     TitleBar.TextSize = uiTextSize + 1 -- Slightly larger for title
  497.     TitleBar.TextColor3 = accentColor -- Accent for title text
  498.  
  499.     -- Apply to CollapseButton
  500.     CollapseButton.Font = uiFont
  501.     CollapseButton.TextSize = uiTextSize + 1
  502.     CollapseButton.TextColor3 = accentColor
  503.  
  504.     -- Apply to existing elements in Container
  505.     for _, child in ipairs(Container:GetChildren()) do
  506.         if child:IsA("TextLabel") or child:IsA("TextButton") then
  507.             child.Font = uiFont
  508.             child.TextSize = uiTextSize
  509.         end
  510.         -- Special handling for elements with accent colors (e.g., buttons, sliders)
  511.         if child:IsA("TextButton") and child.Name ~= "CollapseButton" then
  512.             -- For buttons, we might want to keep their existing background/text colors
  513.             -- or adjust based on a new scheme. For now, just set font/size.
  514.         elseif child:IsA("Frame") and child.Name == "sliderFG" then -- Assuming slider fill frame
  515.             child.BackgroundColor3 = accentColor
  516.         end
  517.     end
  518. end
  519.  
  520. -- API Functions --
  521.  
  522. local function trackAPICall()
  523.     apiCalled = true
  524. end
  525.  
  526. function Nex:SetTitle(text)
  527.     trackAPICall()
  528.     TitleBar.Text = " " .. tostring(text)
  529. end
  530.  
  531. function Nex:AddSection(text)
  532.     trackAPICall()
  533.     local lbl = Instance.new("TextLabel")
  534.     lbl.Text = tostring(text)
  535.     lbl.Font = uiFont
  536.     lbl.TextSize = uiTextSize - 1 -- Slightly smaller for section headers
  537.     lbl.TextColor3 = Color3.fromRGB(180, 180, 180)
  538.     lbl.BackgroundTransparency = 0.8
  539.     lbl.Size = UDim2.new(1, -8, 0, 20)  -- smaller height
  540.     lbl.TextXAlignment = Enum.TextXAlignment.Left
  541.     lbl.Parent = Container
  542. end
  543.  
  544. function Nex:AddButton(text, callback)
  545.     trackAPICall()
  546.     local btn = Instance.new("TextButton")
  547.     btn.Text = tostring(text)
  548.     btn.Font = uiFont
  549.     btn.TextSize = uiTextSize
  550.     btn.Size = UDim2.new(1, -8, 0, 24)
  551.     btn.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  552.     btn.TextColor3 = Color3.fromRGB(255, 255, 255)
  553.     btn.BorderSizePixel = 0
  554.     btn.AutoButtonColor = true
  555.     btn.MouseButton1Click:Connect(callback)
  556.     btn.Parent = Container
  557.     createRounded(btn, 5)
  558.  
  559.     return {
  560.         SetText = function(newText)
  561.             btn.Text = tostring(newText)
  562.         end
  563.     }
  564. end
  565.  
  566. function Nex:AddToggle(text, config, callback)
  567.     trackAPICall()
  568.     if typeof(config) == "function" then
  569.         callback = config
  570.         config = {}
  571.     end
  572.  
  573.     local loop = config.loop
  574.     local toggle = Instance.new("TextButton")
  575.     toggle.Font = uiFont
  576.     toggle.TextSize = uiTextSize
  577.     toggle.Size = UDim2.new(1, -8, 0, 24)
  578.     toggle.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  579.     toggle.BorderSizePixel = 0
  580.     toggle.AutoButtonColor = true
  581.     toggle.Parent = Container
  582.     createRounded(toggle, 5)
  583.  
  584.     local state = false
  585.     local loopingThread = nil
  586.  
  587.     local function updateText()
  588.         local status = state and "[ON] " or "[OFF] "
  589.         local color = state and accentColor or Color3.fromRGB(255, 80, 80) -- Use accent color for ON state
  590.         toggle.Text = status .. text
  591.         toggle.TextColor3 = color
  592.     end
  593.  
  594.     local function updateState(newState, triggerCallback)
  595.         state = newState
  596.         updateText()
  597.         if loop then
  598.             if state then
  599.                 local delayTime = tonumber(config.loopdelay) or 0.2
  600.                 loopingThread = coroutine.create(function()
  601.                     while state do
  602.                         pcall(callback)
  603.                         task.wait(delayTime)
  604.                     end
  605.                 end)
  606.                 coroutine.resume(loopingThread)
  607.             else
  608.                 loopingThread = nil
  609.             end
  610.         elseif triggerCallback then
  611.             pcall(callback, state)
  612.         end
  613.     end
  614.  
  615.     toggle.MouseButton1Click:Connect(function()
  616.         updateState(not state, true)
  617.     end)
  618.  
  619.     updateText()
  620.  
  621.     return {
  622.         Set = function(val)
  623.             if typeof(val) == "boolean" then
  624.                 updateState(val, true)
  625.             end
  626.         end,
  627.         Get = function()
  628.             return state
  629.         end,
  630.         SetText = function(newText)
  631.             text = tostring(newText)
  632.             updateText()
  633.         end
  634.     }
  635. end
  636.  
  637.  
  638. function Nex:AddSlider(text, settings, callback)
  639.     trackAPICall()
  640.     local frame = Instance.new("Frame")
  641.     frame.Size = UDim2.new(1, -8, 0, 35)
  642.     frame.BackgroundTransparency = 1
  643.     frame.Parent = Container
  644.  
  645.     local lbl = Instance.new("TextLabel")
  646.     lbl.Text = text .. ": " .. tostring(settings.default)
  647.     lbl.Font = uiFont
  648.     lbl.TextSize = uiTextSize - 1
  649.     lbl.TextColor3 = Color3.fromRGB(200, 200, 200)
  650.     lbl.BackgroundTransparency = 1
  651.     lbl.Size = UDim2.new(1, 0, 0, 16)
  652.     lbl.TextXAlignment = Enum.TextXAlignment.Left
  653.     lbl.Parent = frame
  654.  
  655.     local sliderBG = Instance.new("Frame")
  656.     sliderBG.Size = UDim2.new(1, 0, 0, 8)
  657.     sliderBG.Position = UDim2.new(0, 0, 0, 22)
  658.     sliderBG.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  659.     sliderBG.BorderSizePixel = 0
  660.     sliderBG.Parent = frame
  661.     createRounded(sliderBG, 5)
  662.  
  663.     local sliderFG = Instance.new("Frame")
  664.     sliderFG.Name = "sliderFG" -- Added name for theme application
  665.     sliderFG.Size = UDim2.new((settings.default - settings.min)/(settings.max-settings.min), 0, 1, 0)
  666.     sliderFG.BackgroundColor3 = accentColor -- Use accent color
  667.     sliderFG.BorderSizePixel = 0
  668.     sliderFG.Parent = sliderBG
  669.     createRounded(sliderFG, 5)
  670.  
  671.     local draggingSlider = false
  672.     local labelText = text
  673.     local currentValue = settings.default
  674.  
  675.     local function setSliderValue(val)
  676.         val = math.clamp(val, settings.min, settings.max)
  677.         local pos = (val - settings.min) / (settings.max - settings.min)
  678.         sliderFG.Size = UDim2.new(pos, 0, 1, 0)
  679.         lbl.Text = labelText .. ": " .. tostring(val)
  680.         currentValue = val
  681.         callback(val)
  682.     end
  683.  
  684.     local function updateSlider(input)
  685.         local pos = math.clamp((input.Position.X - sliderBG.AbsolutePosition.X) / sliderBG.AbsoluteSize.X, 0, 1)
  686.         local value = math.floor(settings.min + (settings.max - settings.min) * pos)
  687.         sliderFG.Size = UDim2.new(pos, 0, 1, 0)
  688.         lbl.Text = labelText .. ": " .. tostring(value)
  689.         currentValue = value
  690.         callback(value)
  691.     end
  692.  
  693.     sliderBG.InputBegan:Connect(function(input)
  694.         if input.UserInputType == Enum.UserInputType.MouseButton1 then
  695.             draggingSlider = true
  696.             updateSlider(input)
  697.         end
  698.     end)
  699.  
  700.     UIS.InputEnded:Connect(function(input)
  701.         if input.UserInputType == Enum.UserInputType.MouseButton1 then
  702.             draggingSlider = false
  703.         end
  704.     end)
  705.  
  706.     UIS.InputChanged:Connect(function(input)
  707.         if draggingSlider and input.UserInputType == Enum.UserInputType.MouseMovement then
  708.             updateSlider(input)
  709.         end
  710.     end)
  711.  
  712.     -- initialize
  713.     setSliderValue(settings.default)
  714.  
  715.     return {
  716.         Set = setSliderValue,
  717.         Get = function()
  718.             return currentValue
  719.         end,
  720.         SetText = function(newText)
  721.             labelText = tostring(newText)
  722.             lbl.Text = labelText .. ": " .. tostring(currentValue)
  723.         end
  724.     }
  725. end
  726.  
  727. function Nex:AddDropdown(labelText, items, buttonText, callback)
  728.     trackAPICall()
  729.     local maxTextSize = uiTextSize
  730.  
  731.     local function applyAutoScale(textObject)
  732.         textObject.TextScaled = true
  733.         local constraint = Instance.new("UITextSizeConstraint")
  734.         constraint.MaxTextSize = maxTextSize
  735.         constraint.MinTextSize = 8
  736.         constraint.Parent = textObject
  737.     end
  738.  
  739.     local UserInputService = game:GetService("UserInputService")
  740.     local CoreGui = game:GetService("CoreGui")
  741.  
  742.     local frame = Instance.new("Frame")
  743.     frame.Size = UDim2.new(1, -8, 0, 30)
  744.     frame.BackgroundTransparency = 1
  745.     frame.Parent = Container
  746.  
  747.     local label = Instance.new("TextLabel")
  748.     label.Text = labelText
  749.     label.Font = uiFont
  750.     label.TextColor3 = Color3.fromRGB(200, 200, 200)
  751.     label.BackgroundTransparency = 1
  752.     label.Size = UDim2.new(0.35, 10, 1, 0)
  753.     label.TextXAlignment = Enum.TextXAlignment.Left
  754.     label.ClipsDescendants = true
  755.     label.TextTruncate = Enum.TextTruncate.AtEnd
  756.     applyAutoScale(label)
  757.     label.Parent = frame
  758.  
  759.     local dropdownButton = Instance.new("TextButton")
  760.     dropdownButton.Font = uiFont
  761.     dropdownButton.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  762.     dropdownButton.BorderSizePixel = 0
  763.     dropdownButton.Size = UDim2.new(0.4, 0, 1, 0)
  764.     dropdownButton.Position = UDim2.new(0.35, 5, 0, 0)
  765.     dropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  766.     dropdownButton.Text = items[1] or "Select"
  767.     dropdownButton.ClipsDescendants = true
  768.     dropdownButton.TextTruncate = Enum.TextTruncate.AtEnd
  769.     applyAutoScale(dropdownButton)
  770.     dropdownButton.Parent = frame
  771.     createRounded(dropdownButton, 5)
  772.  
  773.     local actionButton = Instance.new("TextButton")
  774.     actionButton.Font = uiFont
  775.     actionButton.BackgroundColor3 = accentColor -- Use accent color
  776.     actionButton.BorderSizePixel = 0
  777.     actionButton.Size = UDim2.new(0.22, 0, 1, 0)
  778.     actionButton.Position = UDim2.new(0.75, 10, 0, 0)
  779.     actionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  780.     actionButton.Text = buttonText or "Execute"
  781.     actionButton.ClipsDescendants = true
  782.     actionButton.TextTruncate = Enum.TextTruncate.AtEnd
  783.     applyAutoScale(actionButton)
  784.     actionButton.Parent = frame
  785.     createRounded(actionButton, 5)
  786.  
  787.     local dropdownGui = Instance.new("ScreenGui")
  788.     dropdownGui.Name = "NexDropdownPopup"
  789.     dropdownGui.ResetOnSpawn = false
  790.     dropdownGui.Parent = CoreGui
  791.  
  792.     local dropdownList = Instance.new("ScrollingFrame")
  793.     dropdownList.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  794.     dropdownList.BorderSizePixel = 0
  795.     dropdownList.Size = UDim2.new(0, 150, 0, 0)
  796.     dropdownList.Visible = false
  797.     dropdownList.Parent = dropdownGui
  798.     dropdownList.ScrollBarThickness = 6
  799.     dropdownList.VerticalScrollBarInset = Enum.ScrollBarInset.Always
  800.     createRounded(dropdownList, 5)
  801.  
  802.     local uiListLayout = Instance.new("UIListLayout")
  803.     uiListLayout.Padding = UDim.new(0, 2)
  804.     uiListLayout.Parent = dropdownList
  805.  
  806.     local inputConnection
  807.     local selectedIndex = 1
  808.  
  809.     local function closeDropdown()
  810.         dropdownList.Visible = false
  811.         if inputConnection then
  812.             inputConnection:Disconnect()
  813.             inputConnection = nil
  814.         end
  815.     end
  816.  
  817.     local function refreshItems()
  818.         for _, child in ipairs(dropdownList:GetChildren()) do
  819.             if child:IsA("TextButton") then child:Destroy() end
  820.         end
  821.  
  822.         local itemHeight = 26
  823.         local totalHeight = math.min(#items, 7) * itemHeight
  824.         dropdownList.Size = UDim2.new(0, dropdownButton.AbsoluteSize.X, 0, totalHeight)
  825.         dropdownList.CanvasSize = UDim2.new(0, 0, 0, #items * itemHeight)
  826.  
  827.         for i, itemText in ipairs(items) do
  828.             local itemBtn = Instance.new("TextButton")
  829.             itemBtn.Size = UDim2.new(1, 0, 0, 24)
  830.             itemBtn.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  831.             itemBtn.BorderSizePixel = 0
  832.             itemBtn.Text = itemText
  833.             itemBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
  834.             itemBtn.Font = uiFont
  835.             itemBtn.ClipsDescendants = true
  836.             itemBtn.TextTruncate = Enum.TextTruncate.AtEnd
  837.             applyAutoScale(itemBtn)
  838.             itemBtn.Parent = dropdownList
  839.             createRounded(itemBtn, 4)
  840.  
  841.             itemBtn.MouseButton1Click:Connect(function()
  842.                 selectedIndex = i
  843.                 dropdownButton.Text = itemText
  844.                 closeDropdown()
  845.             end)
  846.         end
  847.     end
  848.  
  849.     refreshItems()
  850.  
  851.     dropdownButton.MouseButton1Click:Connect(function()
  852.         if dropdownList.Visible then
  853.             closeDropdown()
  854.             return
  855.         end
  856.  
  857.         local btnPos = dropdownButton.AbsolutePosition
  858.         local btnSize = dropdownButton.AbsoluteSize
  859.  
  860.         dropdownList.Position = UDim2.new(0, btnPos.X, 0, btnPos.Y + btnSize.Y)
  861.         dropdownList.Visible = true
  862.  
  863.         inputConnection = UserInputService.InputBegan:Connect(function(input)
  864.             if not dropdownList.Visible then return end
  865.  
  866.             if input.UserInputType == Enum.UserInputType.MouseButton1 then
  867.                 local mousePos = input.Position
  868.  
  869.                 local dropAbsPos = dropdownList.AbsolutePosition
  870.                 local dropAbsSize = dropdownList.AbsoluteSize
  871.                 local inDropdown = mousePos.X >= dropAbsPos.X and mousePos.X <= dropAbsPos.X + dropAbsSize.X
  872.                     and mousePos.Y >= dropAbsPos.Y and mousePos.Y <= dropAbsPos.Y + dropAbsSize.Y
  873.  
  874.                 local btnAbsPos = dropdownButton.AbsolutePosition
  875.                 local btnAbsSize = dropdownButton.AbsoluteSize
  876.                 local inButton = mousePos.X >= btnAbsPos.X and mousePos.X <= btnAbsPos.X + btnAbsSize.X
  877.                     and mousePos.Y >= btnAbsPos.Y and mousePos.Y <= btnAbsPos.Y + btnAbsSize.Y
  878.  
  879.                 if not inDropdown and not inButton then
  880.                     closeDropdown()
  881.                 end
  882.             end
  883.         end)
  884.     end)
  885.  
  886.     actionButton.MouseButton1Click:Connect(function()
  887.         if callback and selectedIndex and items[selectedIndex] then
  888.             callback(items[selectedIndex], selectedIndex)
  889.         end
  890.     end)
  891.  
  892.     frame.Destroying:Connect(function()
  893.         if inputConnection then
  894.             inputConnection:Disconnect()
  895.             inputConnection = nil
  896.         end
  897.         dropdownGui:Destroy()
  898.     end)
  899.  
  900.     local dropdownObj = {}
  901.  
  902.     function dropdownObj:SetItems(newItems)
  903.         items = newItems
  904.         selectedIndex = (#items > 0) and 1 or nil
  905.         dropdownButton.Text = items[selectedIndex] or "Select"
  906.         refreshItems()
  907.     end
  908.  
  909.     function dropdownObj:AddItem(item)
  910.         table.insert(items, item)
  911.         refreshItems()
  912.     end
  913.  
  914.     function dropdownObj:SetButtonText(newText)
  915.         actionButton.Text = newText
  916.     end
  917.  
  918.     return dropdownObj
  919. end
  920.  
  921. function Nex:Color(r, g, b)
  922.     trackAPICall()
  923.     if typeof(r) == "number" and typeof(g) == "number" and typeof(b) == "number" then
  924.         accentColor = Color3.fromRGB(r, g, b)
  925.         applyUITheme()
  926.     else
  927.         warn("Nex:Color expects three numbers (R, G, B).")
  928.     end
  929. end
  930.  
  931. function Nex:Font(fontEnum, size)
  932.     trackAPICall()
  933.     if typeof(fontEnum) == "EnumItem" and fontEnum.EnumType == Enum.Font then
  934.         uiFont = fontEnum
  935.         if typeof(size) == "number" then
  936.             uiTextSize = size
  937.         end
  938.         applyUITheme()
  939.     else
  940.         warn("Nex:Font expects an Enum.Font and an optional number for size.")
  941.     end
  942. end
  943.  
  944. function Nex:addKeybind(title, toggleTitle, callback)
  945.     trackAPICall()
  946.     local frame = Instance.new("Frame")
  947.     frame.Size = UDim2.new(1, -8, 0, 60)
  948.     frame.BackgroundTransparency = 1
  949.     frame.Parent = Container
  950.  
  951.     -- Label for the function
  952.     local titleLabel = Instance.new("TextLabel")
  953.     titleLabel.Text = tostring(title)
  954.     titleLabel.Font = uiFont
  955.     titleLabel.TextSize = uiTextSize
  956.     titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  957.     titleLabel.BackgroundTransparency = 1
  958.     titleLabel.Size = UDim2.new(1, 0, 0, 18)
  959.     titleLabel.TextXAlignment = Enum.TextXAlignment.Left
  960.     titleLabel.Parent = frame
  961.  
  962.     -- Text box for keybind input
  963.     local keybindTextBox = Instance.new("TextBox")
  964.     keybindTextBox.PlaceholderText = "Click to set key..."
  965.     keybindTextBox.Text = "[None]"
  966.     keybindTextBox.Font = uiFont
  967.     keybindTextBox.TextSize = uiTextSize
  968.     keybindTextBox.TextColor3 = Color3.fromRGB(200, 200, 200)
  969.     keybindTextBox.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  970.     keybindTextBox.BorderSizePixel = 0
  971.     keybindTextBox.Size = UDim2.new(0.6, 0, 0, 24)
  972.     keybindTextBox.Position = UDim2.new(0, 0, 0, 20)
  973.     keybindTextBox.TextXAlignment = Enum.TextXAlignment.Center
  974.     keybindTextBox.ClearTextOnFocus = false
  975.     keybindTextBox.Parent = frame
  976.     createRounded(keybindTextBox, 5)
  977.  
  978.     -- Toggle (red/green slider)
  979.     local toggleFrame = Instance.new("Frame")
  980.     toggleFrame.Size = UDim2.new(0.3, 0, 0, 24)
  981.     toggleFrame.Position = UDim2.new(0.65, 0, 0, 20)
  982.     toggleFrame.BackgroundColor3 = Color3.fromRGB(255, 80, 80) -- Default OFF color (red)
  983.     toggleFrame.BorderSizePixel = 0
  984.     toggleFrame.Parent = frame
  985.     createRounded(toggleFrame, 12)
  986.  
  987.     local toggleCircle = Instance.new("Frame")
  988.     toggleCircle.Size = UDim2.new(0, 20, 1, 0)
  989.     toggleCircle.Position = UDim2.new(0, 2, 0, 0) -- Left for OFF state
  990.     toggleCircle.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  991.     toggleCircle.BorderSizePixel = 0
  992.     toggleCircle.Parent = toggleFrame
  993.     createRounded(toggleCircle, 10)
  994.  
  995.     local toggleLabel = Instance.new("TextLabel")
  996.     toggleLabel.Text = toggleTitle or "Enabled"
  997.     toggleLabel.Font = uiFont
  998.     toggleLabel.TextSize = uiTextSize - 2
  999.     toggleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  1000.     toggleLabel.BackgroundTransparency = 1
  1001.     toggleLabel.Size = UDim2.new(1, 0, 1, 0)
  1002.     toggleLabel.TextXAlignment = Enum.TextXAlignment.Center
  1003.     toggleLabel.Parent = toggleFrame
  1004.  
  1005.     local isKeybindEnabled = false
  1006.     local currentKeybind = nil
  1007.     local inputConnection = nil
  1008.  
  1009.     local function updateToggleVisual()
  1010.         local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad)
  1011.         if isKeybindEnabled then
  1012.             TweenService:Create(toggleFrame, tweenInfo, {BackgroundColor3 = accentColor}):Play() -- ON color (accent)
  1013.             TweenService:Create(toggleCircle, tweenInfo, {Position = UDim2.new(1, -22, 0, 0)}):Play() -- Move right
  1014.         else
  1015.             TweenService:Create(toggleFrame, tweenInfo, {BackgroundColor3 = Color3.fromRGB(255, 80, 80)}):Play() -- OFF color (red)
  1016.             TweenService:Create(toggleCircle, tweenInfo, {Position = UDim2.new(0, 2, 0, 0)}):Play() -- Move left
  1017.         end
  1018.     end
  1019.  
  1020.     local function connectKeybind()
  1021.         if inputConnection then
  1022.             inputConnection:Disconnect()
  1023.             inputConnection = nil
  1024.         end
  1025.         if isKeybindEnabled and currentKeybind then
  1026.             inputConnection = UIS.InputBegan:Connect(function(input, gameProcessed)
  1027.                 if not gameProcessed and input.KeyCode == currentKeybind then
  1028.                     pcall(callback)
  1029.                 end
  1030.             end)
  1031.         end
  1032.     end
  1033.  
  1034.     toggleFrame.MouseButton1Click:Connect(function()
  1035.         isKeybindEnabled = not isKeybindEnabled
  1036.         updateToggleVisual()
  1037.         connectKeybind()
  1038.     end)
  1039.  
  1040.     keybindTextBox.InputBegan:Connect(function(input)
  1041.         if input.UserInputType == Enum.UserInputType.MouseButton1 then
  1042.             keybindTextBox.Text = "Press a key..."
  1043.             keybindTextBox.TextEditable = false
  1044.             local inputEndedConn
  1045.             inputEndedConn = UIS.InputEnded:Connect(function(inputFinished)
  1046.                 if inputFinished.UserInputType == Enum.UserInputType.Keyboard then
  1047.                     currentKeybind = inputFinished.KeyCode
  1048.                     keybindTextBox.Text = currentKeybind.Name
  1049.                     keybindTextBox.TextEditable = true
  1050.                     connectKeybind()
  1051.                     inputEndedConn:Disconnect()
  1052.                 end
  1053.             end)
  1054.         end
  1055.     end)
  1056.  
  1057.     updateToggleVisual() -- Initial state
  1058.     connectKeybind() -- Initial connection for existing keybind (if any)
  1059.  
  1060.     return {
  1061.         SetKeybind = function(keyCode)
  1062.             if typeof(keyCode) == "EnumItem" and keyCode.EnumType == Enum.KeyCode then
  1063.                 currentKeybind = keyCode
  1064.                 keybindTextBox.Text = currentKeybind.Name
  1065.                 connectKeybind()
  1066.             else
  1067.                 warn("Nex:addKeybind:SetKeybind expects an Enum.KeyCode.")
  1068.             end
  1069.         },
  1070.         SetEnabled = function(enabled)
  1071.             if typeof(enabled) == "boolean" then
  1072.                 isKeybindEnabled = enabled
  1073.                 updateToggleVisual()
  1074.                 connectKeybind()
  1075.             else
  1076.                 warn("Nex:addKeybind:SetEnabled expects a boolean.")
  1077.             end
  1078.         },
  1079.         GetState = function()
  1080.             return isKeybindEnabled, currentKeybind
  1081.         end
  1082.     }
  1083. end
  1084.  
  1085. -- Initial application of the default theme
  1086. applyUITheme()
  1087.  
  1088. -- Demo Usage Script (auto-loads if no API calls are made)
  1089. task.delay(0.1, function() -- Small delay to allow for immediate API calls
  1090.     if not apiCalled then
  1091.         Nex:SetTitle("NexusLib Demo")
  1092.  
  1093.         Nex:AddSection("Player Controls")
  1094.  
  1095.         Nex:AddButton("WalkSpeed to 50", function()
  1096.             player.Character.Humanoid.WalkSpeed = 50
  1097.             Nex:Notify("WalkSpeed set to 50!", 2, "S")
  1098.         end)
  1099.  
  1100.         local jumpToggle = Nex:AddToggle("AutoJump", {loop = true, loopdelay = 0.1}, function()
  1101.             if player.Character and player.Character.Humanoid then
  1102.                 player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
  1103.             end
  1104.         end)
  1105.  
  1106.         Nex:AddButton("Toggle AutoJump", function()
  1107.             jumpToggle.Set(not jumpToggle.Get())
  1108.             Nex:Notify("AutoJump Toggled: " .. tostring(jumpToggle.Get()), 2, "D")
  1109.         end)
  1110.  
  1111.         local walkSpeedSlider = Nex:AddSlider("WalkSpeed", {min = 16, max = 100, default = 16}, function(value)
  1112.             if player.Character and player.Character.Humanoid then
  1113.                 player.Character.Humanoid.WalkSpeed = value
  1114.             end
  1115.             Nex:Notify("WalkSpeed: " .. tostring(value), 1, "D")
  1116.         end)
  1117.  
  1118.         Nex:AddSection("Teleportation")
  1119.  
  1120.         local tpOptions = {"Spawn", "Mouse", "Opponent"}
  1121.         local dropdown = Nex:AddDropdown("Teleport To", tpOptions, "Teleport", function(selectedItem, index)
  1122.             if selectedItem == "Spawn" then
  1123.                 player.Character:SetPrimaryPartCFrame(CFrame.new(game.Workspace.SpawnLocation.Position))
  1124.                 Nex:Notify("Teleported to Spawn!", 2, "S")
  1125.             elseif selectedItem == "Mouse" then
  1126.                 local mouse = player:GetMouse()
  1127.                 if mouse.Hit then
  1128.                     player.Character:SetPrimaryPartCFrame(mouse.Hit + Vector3.new(0, 3, 0))
  1129.                     Nex:Notify("Teleported to Mouse!", 2, "S")
  1130.                 else
  1131.                     Nex:Notify("Invalid mouse target!", 2, "E")
  1132.                 end
  1133.             elseif selectedItem == "Opponent" then
  1134.                 local enemies = {}
  1135.                 for _, p in pairs(Players:GetPlayers()) do
  1136.                     if p.Name ~= player.Name and p.Character and p.Character:FindFirstChildOfClass("Humanoid") then
  1137.                         table.insert(enemies, p.Character.HumanoidRootPart.Position)
  1138.                     end
  1139.                 end
  1140.                 if #enemies > 0 then
  1141.                     local randomEnemyPos = enemies[math.random(1, #enemies)]
  1142.                     player.Character:SetPrimaryPartCFrame(CFrame.new(randomEnemyPos + Vector3.new(0, 3, 0)))
  1143.                     Nex:Notify("Teleported to opponent!", 2, "S")
  1144.                 else
  1145.                     Nex:Notify("No opponents found!", 2, "E")
  1146.                 end
  1147.             end
  1148.         end)
  1149.  
  1150.         Nex:AddSection("Theme Settings")
  1151.  
  1152.         Nex:AddButton("Change Accent Color (Red)", function()
  1153.             Nex:Color(255, 0, 0)
  1154.             Nex:Notify("Accent Color set to Red!", 2, "S")
  1155.         end)
  1156.  
  1157.         Nex:AddButton("Change Accent Color (Green)", function()
  1158.             Nex:Color(0, 255, 0)
  1159.             Nex:Notify("Accent Color set to Green!", 2, "S")
  1160.         end)
  1161.  
  1162.         local keybind = Nex:addKeybind("Toggle Noclip", "Noclip Enabled", function()
  1163.             -- Simple Noclip Toggle (requires character and humanoid)
  1164.             if player.Character and player.Character.Humanoid then
  1165.                 local humanoid = player.Character.Humanoid
  1166.                 humanoid.WalkSpeed = (humanoid.WalkSpeed == 0) and 16 or 0
  1167.                 for _, part in ipairs(player.Character:GetDescendants()) do
  1168.                     if part:IsA("BasePart") then
  1169.                         part.CanCollide = not part.CanCollide
  1170.                     end
  1171.                 end
  1172.                 Nex:Notify("Noclip Toggled!", 1.5, "D")
  1173.             else
  1174.                 Nex:Notify("Noclip requires a character!", 1.5, "E")
  1175.             end
  1176.         })
  1177.         keybind.SetKeybind(Enum.KeyCode.Q) -- Default keybind to 'Q'
  1178.  
  1179.         Nex:Notify("NexusLib Demo Loaded!", 3, "S")
  1180.     end
  1181. end)
  1182.  
  1183.  
  1184. return Nex
Advertisement
Add Comment
Please, Sign In to add comment