Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// NexusLib V3.2 by NexusRobloxScripts
- --// 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.
- --// TO ADD: Improve UI Animations, transition, color scheme, etc
- --// TO ADD: Allow users to modify UI Accent colors and fonts via APi calls like Nex:Font and Nex:Color (RGB code)
- --// 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)
- local TweenService = game:GetService("TweenService")
- local player = game.Players.LocalPlayer
- local Players = game:GetService("Players")
- local parentGui = game:GetService("CoreGui")
- local Lighting = game:GetService("Lighting")
- local playerGui = player:WaitForChild("PlayerGui")
- local notificationQueue = {}
- local activeNotifications = 0
- local MAX_NOTIFICATIONS = 3
- local activeNotificationFrames = {}
- local UIS = game:GetService("UserInputService")
- local Nex = {}
- -- Global variables for accent color and font
- local accentColor = Color3.fromRGB(0, 170, 255) -- Default accent color
- local uiFont = Enum.Font.Gotham -- Default font
- local uiTextSize = 13 -- Default text size
- -- Flag to check if any API functions were called
- local apiCalled = false
- --// Handle GUI parent fallbacks (e.g., CoreGui not accessible)
- pcall(function()
- if not parentGui:IsDescendantOf(game) then
- parentGui = player:WaitForChild("PlayerGui")
- end
- end)
- --// Remove any existing credit popup or library UI
- local oldPopup = parentGui:FindFirstChild("CreditPopup")
- if oldPopup then oldPopup:Destroy() end
- local oldLibUI = parentGui:FindFirstChild("NexusLib")
- if oldLibUI then oldLibUI:Destroy() end
- -- 🧱 Create reusable rounded corner
- local function createRounded(instance, radius)
- local corner = Instance.new("UICorner")
- corner.CornerRadius = UDim.new(0, radius or 6)
- corner.Parent = instance
- end
- --// NOTIFICATION MODULE:
- -- Find or fallback for main UI ScreenGui to parent notifications inside it
- local ScreenGui = parentGui:FindFirstChild("NexusLib")
- if not ScreenGui then
- ScreenGui = player:WaitForChild("PlayerGui"):FindFirstChild("NexusLib")
- if not ScreenGui then
- ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Name = "NexusLib"
- ScreenGui.ResetOnSpawn = false
- ScreenGui.IgnoreGuiInset = true
- ScreenGui.DisplayOrder = 10
- ScreenGui.Parent = player:WaitForChild("PlayerGui")
- print("[Notification] Created fallback NexusLib ScreenGui in PlayerGui")
- end
- end
- -- 📌 Notification container for up to 3 notifications, bottom-centered
- local NotificationContainer = Instance.new("Frame")
- NotificationContainer.Name = "NotificationContainer"
- NotificationContainer.AnchorPoint = Vector2.new(1, 1) -- bottom-right anchor
- NotificationContainer.Position = UDim2.new(1, -15, 1, -15) -- bottom right with margin offsets
- NotificationContainer.Size = UDim2.new(0, 300, 0, 165) -- size for ~3 notifications
- NotificationContainer.BackgroundTransparency = 1
- NotificationContainer.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
- NotificationContainer.ZIndex = 10
- NotificationContainer.ClipsDescendants = false
- NotificationContainer.Visible = true
- NotificationContainer.Parent = ScreenGui
- print("[Notification] NotificationContainer created and parented to", NotificationContainer.Parent:GetFullName())
- -- 🖼️ Type styling helper
- local function getTypeStyle(notificationType)
- local icon, color
- if notificationType == "S" then
- icon = "✅"
- color = Color3.fromRGB(0, 200, 100)
- elseif notificationType == "E" then
- icon = "⚠️"
- color = Color3.fromRGB(255, 180, 0)
- else
- icon = "📢"
- color = Color3.fromRGB(0, 170, 255)
- end
- return icon, color
- end
- -- 🔁 Process the notification queue
- local function processQueue()
- if activeNotifications >= MAX_NOTIFICATIONS then return end
- if #notificationQueue == 0 then return end
- local data = table.remove(notificationQueue, 1)
- activeNotifications += 1
- local notif = Instance.new("Frame")
- notif.Size = UDim2.new(1, 0, 0, 50)
- notif.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- notif.BorderSizePixel = 0
- notif.BackgroundTransparency = 0
- notif.ClipsDescendants = true
- notif.ZIndex = 11
- notif.Visible = true
- notif.Parent = NotificationContainer
- createRounded(notif, 6)
- -- Add new notification at the BOTTOM of active list (end)
- table.insert(activeNotificationFrames, notif)
- -- Recalculate positions from top (oldest) to bottom (newest)
- for i, frame in ipairs(activeNotificationFrames) do
- local targetY = -165 + (i - 1) * 55 -- Start at top edge, move down 55 px each
- TweenService:Create(frame, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
- Position = UDim2.new(0, 0, 1, targetY)
- }):Play()
- end
- -- Start below container bottom, slide up into place at bottom (newest slot)
- notif.Position = UDim2.new(0, 0, 1, 60)
- local icon, strokeColor = getTypeStyle(data.type)
- local stroke = Instance.new("UIStroke")
- stroke.Color = strokeColor
- stroke.Thickness = 1
- stroke.Transparency = 0.3
- stroke.Parent = notif
- local label = Instance.new("TextLabel")
- label.Text = icon .. " " .. data.text
- label.Font = Enum.Font.Gotham
- label.TextSize = 14
- label.TextColor3 = Color3.fromRGB(255, 255, 255)
- label.BackgroundTransparency = 1
- label.TextWrapped = true
- label.TextXAlignment = Enum.TextXAlignment.Left
- label.Size = UDim2.new(1, -16, 1, -16)
- label.Position = UDim2.new(0, 8, 0, 4)
- label.ZIndex = 12
- label.Parent = notif
- local progress = Instance.new("Frame")
- progress.Size = UDim2.new(1, 0, 0, 3)
- progress.Position = UDim2.new(0, 0, 1, -3)
- progress.BackgroundColor3 = strokeColor
- progress.BorderSizePixel = 0
- progress.ZIndex = 13
- progress.Parent = notif
- createRounded(progress, 3)
- local progressTween = TweenService:Create(progress, TweenInfo.new(data.duration, Enum.EasingStyle.Linear), {
- Size = UDim2.new(0, 0, 0, 3)
- })
- progressTween:Play()
- task.delay(data.duration, function()
- local fade = TweenService:Create(notif, TweenInfo.new(0.4), {BackgroundTransparency = 1})
- local labelFade = TweenService:Create(label, TweenInfo.new(0.4), {TextTransparency = 1})
- local progressFade = TweenService:Create(progress, TweenInfo.new(0.3), {BackgroundTransparency = 1})
- progressTween:Cancel()
- fade:Play()
- labelFade:Play()
- progressFade:Play()
- task.wait(0.4)
- notif:Destroy()
- activeNotifications -= 1
- -- Remove from list
- for i, frame in ipairs(activeNotificationFrames) do
- if frame == notif then
- table.remove(activeNotificationFrames, i)
- break
- end
- end
- -- Re-stack remaining from top (oldest) to bottom (newest)
- for i, frame in ipairs(activeNotificationFrames) do
- local targetY = -165 + (i - 1) * 55
- TweenService:Create(frame, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
- Position = UDim2.new(0, 0, 1, targetY)
- }):Play()
- end
- processQueue()
- end)
- end
- -- 📣 Main Notify function for Nex
- function Nex:Notify(text, duration, notificationType)
- print("[Notification] Adding notification to queue:", text)
- table.insert(notificationQueue, {
- text = tostring(text),
- duration = duration or 5,
- type = notificationType or "D"
- })
- processQueue()
- end
- --// Credits
- --// Blur background
- local blur = Instance.new("BlurEffect")
- blur.Size = 0
- blur.Name = "NexCreditBlur"
- blur.Parent = Lighting
- TweenService:Create(blur, TweenInfo.new(0.5), {Size = 12}):Play()
- --// GUI container
- local gui = Instance.new("ScreenGui")
- gui.Name = "CreditPopup"
- gui.IgnoreGuiInset = true
- gui.ResetOnSpawn = false
- gui.Parent = parentGui
- --// Main popup frame
- local popup = Instance.new("Frame")
- popup.Size = UDim2.new(0, 280, 0, 80)
- popup.Position = UDim2.new(0.5, 0, 0.5, 0)
- popup.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
- popup.BackgroundTransparency = 1
- popup.BorderSizePixel = 0
- popup.AnchorPoint = Vector2.new(0.5, 0.5)
- popup.Parent = gui
- -- Rounded corners and stroke
- Instance.new("UICorner", popup).CornerRadius = UDim.new(0, 8)
- local stroke = Instance.new("UIStroke", popup)
- stroke.Color = Color3.fromRGB(0, 170, 255)
- stroke.Thickness = 2
- stroke.Transparency = 0.4
- --// Icon image
- local icon = Instance.new("ImageLabel")
- icon.Size = UDim2.new(0, 40, 0, 40)
- icon.Position = UDim2.new(0, 10, 0, 20)
- icon.BackgroundTransparency = 1
- icon.Image = "rbxassetid://6031075938"
- icon.ScaleType = Enum.ScaleType.Fit
- icon.ClipsDescendants = true
- icon.ImageTransparency = 1
- icon.Parent = popup
- Instance.new("UIAspectRatioConstraint", icon).AspectRatio = 1
- --// Text: Title
- local mainLabel = Instance.new("TextLabel")
- mainLabel.Position = UDim2.new(0, 60, 0, 12)
- mainLabel.Size = UDim2.new(1, -70, 0, 24)
- mainLabel.BackgroundTransparency = 1
- mainLabel.Text = "NexusLib UI"
- mainLabel.Font = Enum.Font.GothamBold
- mainLabel.TextSize = 16
- mainLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- mainLabel.TextXAlignment = Enum.TextXAlignment.Left
- mainLabel.Parent = popup
- --// Text: Link
- local socialLink = Instance.new("TextButton")
- socialLink.Position = UDim2.new(0, 60, 0, 40)
- socialLink.Size = UDim2.new(1, -70, 0, 18)
- socialLink.BackgroundTransparency = 1
- socialLink.Text = "@NexusRobloxScripts"
- socialLink.Font = Enum.Font.Gotham
- socialLink.TextSize = 13
- socialLink.TextColor3 = Color3.fromRGB(0, 170, 255)
- socialLink.TextXAlignment = Enum.TextXAlignment.Left
- socialLink.AutoButtonColor = false
- socialLink.Parent = popup
- -- Added functionality to copy the link and notify
- local url = "https://youtube.com/NexusRobloxScripts"
- socialLink.MouseButton1Click:Connect(function()
- -- Copy to clipboard (works on executors like Delta)
- if setclipboard then
- setclipboard(url)
- Nex:Notify("YouTube Link Copied!", 3, "S")
- end
- end)
- --// Loading bar background
- local loadingBarBg = Instance.new("Frame")
- loadingBarBg.Size = UDim2.new(0, 180, 0, 12) -- made narrower
- loadingBarBg.Position = UDim2.new(0, 60, 0, 65) -- same position
- loadingBarBg.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- loadingBarBg.BorderSizePixel = 0
- loadingBarBg.AnchorPoint = Vector2.new(0, 0)
- loadingBarBg.Parent = popup
- Instance.new("UICorner", loadingBarBg).CornerRadius = UDim.new(0, 6)
- --// Loading bar fill
- local loadingBarFill = Instance.new("Frame")
- loadingBarFill.Size = UDim2.new(0, 0, 1, 0) -- starts empty
- loadingBarFill.Position = UDim2.new(0, 0, 0, 0)
- loadingBarFill.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
- loadingBarFill.BorderSizePixel = 0
- loadingBarFill.Parent = loadingBarBg
- Instance.new("UICorner", loadingBarFill).CornerRadius = UDim.new(0, 6)
- --// Percentage label
- local loadingPercent = Instance.new("TextLabel")
- loadingPercent.Size = UDim2.new(0, 40, 0, 12) -- slightly smaller width
- loadingPercent.Position = UDim2.new(1, -45, 0, 0) -- moved left inside the bar's right edge
- loadingPercent.BackgroundTransparency = 1
- loadingPercent.Text = "0%"
- loadingPercent.Font = Enum.Font.GothamBold
- loadingPercent.TextSize = 12
- loadingPercent.TextColor3 = Color3.fromRGB(255, 255, 255)
- loadingPercent.TextXAlignment = Enum.TextXAlignment.Right -- right-align to fit nicely
- loadingPercent.Parent = loadingBarBg
- --// Fade in popup
- TweenService:Create(popup, TweenInfo.new(0.5), {BackgroundTransparency = 0}):Play()
- TweenService:Create(icon, TweenInfo.new(0.5), {ImageTransparency = 0}):Play()
- --// Update loading bar over time instead of static wait
- local displayTime = 3 -- Reduced display time for faster load
- local updateInterval = 0.05
- for elapsed = 0, displayTime, updateInterval do
- local progress = elapsed / displayTime
- local percent = math.floor(progress * 100)
- loadingBarFill.Size = UDim2.new(progress, 0, 1, 0)
- loadingPercent.Text = percent .. "%"
- task.wait(updateInterval)
- end
- -- Ensure fully filled at end
- loadingBarFill.Size = UDim2.new(1, 0, 1, 0)
- loadingPercent.Text = "100%"
- --// Fade out popup
- TweenService:Create(popup, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
- TweenService:Create(icon, TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
- TweenService:Create(blur, TweenInfo.new(0.5), {Size = 0}):Play()
- --// Cleanup after fade
- task.delay(0.5, function()
- blur:Destroy()
- gui:Destroy()
- end)
- -- START OF THE UI MAIN WINDOW, SEE COMMENTS FOR INFO!!!!
- local isCollapsed = true
- local dragging, dragStart, startPos
- -- UI Container
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Name = "NexusLib"
- ScreenGui.ResetOnSpawn = false
- ScreenGui.IgnoreGuiInset = true
- ScreenGui.Parent = parentGui
- -- Main Window
- local MainFrame = Instance.new("Frame")
- MainFrame.Name = "MainFrame"
- MainFrame.Position = UDim2.new(0.3, 0, 0.3, 0)
- MainFrame.Size = UDim2.new(0, 250, 0, 25) -- collapsed size (more rectangular horizontally)
- MainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
- MainFrame.BorderSizePixel = 0
- MainFrame.Active = true
- MainFrame.Parent = ScreenGui
- createRounded(MainFrame, 6) -- slightly smaller corner radius
- local UIStroke = Instance.new("UIStroke", MainFrame)
- UIStroke.Thickness = 1.5
- UIStroke.Color = accentColor
- UIStroke.Transparency = 0.3
- -- Title Bar
- local TitleBar = Instance.new("TextButton")
- TitleBar.Text = " UI Menu "
- TitleBar.Font = uiFont
- TitleBar.TextSize = 14 -- smaller font size
- TitleBar.Size = UDim2.new(1, 0, 0, 25) -- shorter height
- TitleBar.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- TitleBar.TextColor3 = Color3.fromRGB(255, 255, 255)
- TitleBar.BorderSizePixel = 0
- TitleBar.AutoButtonColor = false
- TitleBar.Parent = MainFrame
- createRounded(TitleBar, 6)
- -- Collapse Button
- local CollapseButton = Instance.new("TextButton")
- CollapseButton.Size = UDim2.new(0, 25, 1, 0)
- CollapseButton.Position = UDim2.new(1, -25, 0, 0)
- CollapseButton.Text = "+"
- CollapseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- CollapseButton.Font = uiFont
- CollapseButton.TextSize = 14
- CollapseButton.BackgroundTransparency = 1
- CollapseButton.Parent = TitleBar
- -- Add icon to TitleBar
- local titleIcon = Instance.new("ImageLabel")
- titleIcon.Size = UDim2.new(0, 20, 0, 20) -- small square icon
- titleIcon.Position = UDim2.new(0, 5, 0.5, -10) -- left side with vertical center alignment
- titleIcon.BackgroundTransparency = 1
- titleIcon.Image = "rbxassetid://6031075938" -- same asset ID as your popup icon
- titleIcon.ScaleType = Enum.ScaleType.Fit
- titleIcon.Parent = TitleBar
- -- Container (scrolling frame for controls)
- local Container = Instance.new("ScrollingFrame")
- Container.Size = UDim2.new(1, -8, 1, -32)
- Container.Position = UDim2.new(0, 4, 0, 29)
- Container.CanvasSize = UDim2.new(0, 0, 0, 0)
- Container.ScrollBarThickness = 5
- Container.AutomaticCanvasSize = Enum.AutomaticSize.Y
- Container.BackgroundTransparency = 1
- Container.Visible = false
- Container.Parent = MainFrame
- local UIListLayout = Instance.new("UIListLayout", Container)
- UIListLayout.Padding = UDim.new(0, 5) -- smaller padding
- UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
- -- Collapse toggle logic
- CollapseButton.MouseButton1Click:Connect(function()
- isCollapsed = not isCollapsed
- CollapseButton.Text = isCollapsed and "+" or "–"
- local targetSizeX = isCollapsed and 250 or 350 -- Expanded width
- local targetSizeY = isCollapsed and 25 or 320 -- Expanded height (downwards)
- local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out)
- TweenService:Create(MainFrame, tweenInfo, {
- Size = UDim2.new(0, targetSizeX, 0, targetSizeY)
- }):Play()
- -- Fade in/out container (optional, for smoother transition)
- if not isCollapsed then
- Container.Visible = true
- TweenService:Create(Container, TweenInfo.new(0.2, Enum.EasingStyle.Quad), {BackgroundTransparency = 0, ScrollingCanvasBackgroundColor = Color3.fromRGB(20,20,20)}):Play()
- else
- TweenService:Create(Container, TweenInfo.new(0.2, Enum.EasingStyle.Quad), {BackgroundTransparency = 1, ScrollingCanvasBackgroundColor = Color3.fromRGB(20,20,20)}):Play()
- task.wait(0.2) -- Wait for fade out before hiding
- Container.Visible = false
- end
- end)
- -- Draggable logic (exclude collapse button area)
- TitleBar.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if UIS:GetFocusedTextBox() == nil then
- local mousePos = input.Position
- local cbPos = CollapseButton.AbsolutePosition
- local cbSize = CollapseButton.AbsoluteSize
- if not (mousePos.X >= cbPos.X and mousePos.X <= cbPos.X + cbSize.X) then
- dragging = true
- dragStart = input.Position
- startPos = MainFrame.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end
- end
- end)
- UIS.InputChanged:Connect(function(input)
- if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
- local delta = input.Position - dragStart
- MainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
- end
- end)
- -- Function to apply font and color to all existing and future UI elements
- local function applyUITheme()
- -- Apply to MainFrame stroke
- UIStroke.Color = accentColor
- -- Apply to TitleBar
- TitleBar.Font = uiFont
- TitleBar.TextSize = uiTextSize + 1 -- Slightly larger for title
- TitleBar.TextColor3 = accentColor -- Accent for title text
- -- Apply to CollapseButton
- CollapseButton.Font = uiFont
- CollapseButton.TextSize = uiTextSize + 1
- CollapseButton.TextColor3 = accentColor
- -- Apply to existing elements in Container
- for _, child in ipairs(Container:GetChildren()) do
- if child:IsA("TextLabel") or child:IsA("TextButton") then
- child.Font = uiFont
- child.TextSize = uiTextSize
- end
- -- Special handling for elements with accent colors (e.g., buttons, sliders)
- if child:IsA("TextButton") and child.Name ~= "CollapseButton" then
- -- For buttons, we might want to keep their existing background/text colors
- -- or adjust based on a new scheme. For now, just set font/size.
- elseif child:IsA("Frame") and child.Name == "sliderFG" then -- Assuming slider fill frame
- child.BackgroundColor3 = accentColor
- end
- end
- end
- -- API Functions --
- local function trackAPICall()
- apiCalled = true
- end
- function Nex:SetTitle(text)
- trackAPICall()
- TitleBar.Text = " " .. tostring(text)
- end
- function Nex:AddSection(text)
- trackAPICall()
- local lbl = Instance.new("TextLabel")
- lbl.Text = tostring(text)
- lbl.Font = uiFont
- lbl.TextSize = uiTextSize - 1 -- Slightly smaller for section headers
- lbl.TextColor3 = Color3.fromRGB(180, 180, 180)
- lbl.BackgroundTransparency = 0.8
- lbl.Size = UDim2.new(1, -8, 0, 20) -- smaller height
- lbl.TextXAlignment = Enum.TextXAlignment.Left
- lbl.Parent = Container
- end
- function Nex:AddButton(text, callback)
- trackAPICall()
- local btn = Instance.new("TextButton")
- btn.Text = tostring(text)
- btn.Font = uiFont
- btn.TextSize = uiTextSize
- btn.Size = UDim2.new(1, -8, 0, 24)
- btn.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- btn.TextColor3 = Color3.fromRGB(255, 255, 255)
- btn.BorderSizePixel = 0
- btn.AutoButtonColor = true
- btn.MouseButton1Click:Connect(callback)
- btn.Parent = Container
- createRounded(btn, 5)
- return {
- SetText = function(newText)
- btn.Text = tostring(newText)
- end
- }
- end
- function Nex:AddToggle(text, config, callback)
- trackAPICall()
- if typeof(config) == "function" then
- callback = config
- config = {}
- end
- local loop = config.loop
- local toggle = Instance.new("TextButton")
- toggle.Font = uiFont
- toggle.TextSize = uiTextSize
- toggle.Size = UDim2.new(1, -8, 0, 24)
- toggle.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- toggle.BorderSizePixel = 0
- toggle.AutoButtonColor = true
- toggle.Parent = Container
- createRounded(toggle, 5)
- local state = false
- local loopingThread = nil
- local function updateText()
- local status = state and "[ON] " or "[OFF] "
- local color = state and accentColor or Color3.fromRGB(255, 80, 80) -- Use accent color for ON state
- toggle.Text = status .. text
- toggle.TextColor3 = color
- end
- local function updateState(newState, triggerCallback)
- state = newState
- updateText()
- if loop then
- if state then
- local delayTime = tonumber(config.loopdelay) or 0.2
- loopingThread = coroutine.create(function()
- while state do
- pcall(callback)
- task.wait(delayTime)
- end
- end)
- coroutine.resume(loopingThread)
- else
- loopingThread = nil
- end
- elseif triggerCallback then
- pcall(callback, state)
- end
- end
- toggle.MouseButton1Click:Connect(function()
- updateState(not state, true)
- end)
- updateText()
- return {
- Set = function(val)
- if typeof(val) == "boolean" then
- updateState(val, true)
- end
- end,
- Get = function()
- return state
- end,
- SetText = function(newText)
- text = tostring(newText)
- updateText()
- end
- }
- end
- function Nex:AddSlider(text, settings, callback)
- trackAPICall()
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(1, -8, 0, 35)
- frame.BackgroundTransparency = 1
- frame.Parent = Container
- local lbl = Instance.new("TextLabel")
- lbl.Text = text .. ": " .. tostring(settings.default)
- lbl.Font = uiFont
- lbl.TextSize = uiTextSize - 1
- lbl.TextColor3 = Color3.fromRGB(200, 200, 200)
- lbl.BackgroundTransparency = 1
- lbl.Size = UDim2.new(1, 0, 0, 16)
- lbl.TextXAlignment = Enum.TextXAlignment.Left
- lbl.Parent = frame
- local sliderBG = Instance.new("Frame")
- sliderBG.Size = UDim2.new(1, 0, 0, 8)
- sliderBG.Position = UDim2.new(0, 0, 0, 22)
- sliderBG.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- sliderBG.BorderSizePixel = 0
- sliderBG.Parent = frame
- createRounded(sliderBG, 5)
- local sliderFG = Instance.new("Frame")
- sliderFG.Name = "sliderFG" -- Added name for theme application
- sliderFG.Size = UDim2.new((settings.default - settings.min)/(settings.max-settings.min), 0, 1, 0)
- sliderFG.BackgroundColor3 = accentColor -- Use accent color
- sliderFG.BorderSizePixel = 0
- sliderFG.Parent = sliderBG
- createRounded(sliderFG, 5)
- local draggingSlider = false
- local labelText = text
- local currentValue = settings.default
- local function setSliderValue(val)
- val = math.clamp(val, settings.min, settings.max)
- local pos = (val - settings.min) / (settings.max - settings.min)
- sliderFG.Size = UDim2.new(pos, 0, 1, 0)
- lbl.Text = labelText .. ": " .. tostring(val)
- currentValue = val
- callback(val)
- end
- local function updateSlider(input)
- local pos = math.clamp((input.Position.X - sliderBG.AbsolutePosition.X) / sliderBG.AbsoluteSize.X, 0, 1)
- local value = math.floor(settings.min + (settings.max - settings.min) * pos)
- sliderFG.Size = UDim2.new(pos, 0, 1, 0)
- lbl.Text = labelText .. ": " .. tostring(value)
- currentValue = value
- callback(value)
- end
- sliderBG.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- draggingSlider = true
- updateSlider(input)
- end
- end)
- UIS.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- draggingSlider = false
- end
- end)
- UIS.InputChanged:Connect(function(input)
- if draggingSlider and input.UserInputType == Enum.UserInputType.MouseMovement then
- updateSlider(input)
- end
- end)
- -- initialize
- setSliderValue(settings.default)
- return {
- Set = setSliderValue,
- Get = function()
- return currentValue
- end,
- SetText = function(newText)
- labelText = tostring(newText)
- lbl.Text = labelText .. ": " .. tostring(currentValue)
- end
- }
- end
- function Nex:AddDropdown(labelText, items, buttonText, callback)
- trackAPICall()
- local maxTextSize = uiTextSize
- local function applyAutoScale(textObject)
- textObject.TextScaled = true
- local constraint = Instance.new("UITextSizeConstraint")
- constraint.MaxTextSize = maxTextSize
- constraint.MinTextSize = 8
- constraint.Parent = textObject
- end
- local UserInputService = game:GetService("UserInputService")
- local CoreGui = game:GetService("CoreGui")
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(1, -8, 0, 30)
- frame.BackgroundTransparency = 1
- frame.Parent = Container
- local label = Instance.new("TextLabel")
- label.Text = labelText
- label.Font = uiFont
- label.TextColor3 = Color3.fromRGB(200, 200, 200)
- label.BackgroundTransparency = 1
- label.Size = UDim2.new(0.35, 10, 1, 0)
- label.TextXAlignment = Enum.TextXAlignment.Left
- label.ClipsDescendants = true
- label.TextTruncate = Enum.TextTruncate.AtEnd
- applyAutoScale(label)
- label.Parent = frame
- local dropdownButton = Instance.new("TextButton")
- dropdownButton.Font = uiFont
- dropdownButton.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- dropdownButton.BorderSizePixel = 0
- dropdownButton.Size = UDim2.new(0.4, 0, 1, 0)
- dropdownButton.Position = UDim2.new(0.35, 5, 0, 0)
- dropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- dropdownButton.Text = items[1] or "Select"
- dropdownButton.ClipsDescendants = true
- dropdownButton.TextTruncate = Enum.TextTruncate.AtEnd
- applyAutoScale(dropdownButton)
- dropdownButton.Parent = frame
- createRounded(dropdownButton, 5)
- local actionButton = Instance.new("TextButton")
- actionButton.Font = uiFont
- actionButton.BackgroundColor3 = accentColor -- Use accent color
- actionButton.BorderSizePixel = 0
- actionButton.Size = UDim2.new(0.22, 0, 1, 0)
- actionButton.Position = UDim2.new(0.75, 10, 0, 0)
- actionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- actionButton.Text = buttonText or "Execute"
- actionButton.ClipsDescendants = true
- actionButton.TextTruncate = Enum.TextTruncate.AtEnd
- applyAutoScale(actionButton)
- actionButton.Parent = frame
- createRounded(actionButton, 5)
- local dropdownGui = Instance.new("ScreenGui")
- dropdownGui.Name = "NexDropdownPopup"
- dropdownGui.ResetOnSpawn = false
- dropdownGui.Parent = CoreGui
- local dropdownList = Instance.new("ScrollingFrame")
- dropdownList.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- dropdownList.BorderSizePixel = 0
- dropdownList.Size = UDim2.new(0, 150, 0, 0)
- dropdownList.Visible = false
- dropdownList.Parent = dropdownGui
- dropdownList.ScrollBarThickness = 6
- dropdownList.VerticalScrollBarInset = Enum.ScrollBarInset.Always
- createRounded(dropdownList, 5)
- local uiListLayout = Instance.new("UIListLayout")
- uiListLayout.Padding = UDim.new(0, 2)
- uiListLayout.Parent = dropdownList
- local inputConnection
- local selectedIndex = 1
- local function closeDropdown()
- dropdownList.Visible = false
- if inputConnection then
- inputConnection:Disconnect()
- inputConnection = nil
- end
- end
- local function refreshItems()
- for _, child in ipairs(dropdownList:GetChildren()) do
- if child:IsA("TextButton") then child:Destroy() end
- end
- local itemHeight = 26
- local totalHeight = math.min(#items, 7) * itemHeight
- dropdownList.Size = UDim2.new(0, dropdownButton.AbsoluteSize.X, 0, totalHeight)
- dropdownList.CanvasSize = UDim2.new(0, 0, 0, #items * itemHeight)
- for i, itemText in ipairs(items) do
- local itemBtn = Instance.new("TextButton")
- itemBtn.Size = UDim2.new(1, 0, 0, 24)
- itemBtn.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- itemBtn.BorderSizePixel = 0
- itemBtn.Text = itemText
- itemBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
- itemBtn.Font = uiFont
- itemBtn.ClipsDescendants = true
- itemBtn.TextTruncate = Enum.TextTruncate.AtEnd
- applyAutoScale(itemBtn)
- itemBtn.Parent = dropdownList
- createRounded(itemBtn, 4)
- itemBtn.MouseButton1Click:Connect(function()
- selectedIndex = i
- dropdownButton.Text = itemText
- closeDropdown()
- end)
- end
- end
- refreshItems()
- dropdownButton.MouseButton1Click:Connect(function()
- if dropdownList.Visible then
- closeDropdown()
- return
- end
- local btnPos = dropdownButton.AbsolutePosition
- local btnSize = dropdownButton.AbsoluteSize
- dropdownList.Position = UDim2.new(0, btnPos.X, 0, btnPos.Y + btnSize.Y)
- dropdownList.Visible = true
- inputConnection = UserInputService.InputBegan:Connect(function(input)
- if not dropdownList.Visible then return end
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- local mousePos = input.Position
- local dropAbsPos = dropdownList.AbsolutePosition
- local dropAbsSize = dropdownList.AbsoluteSize
- local inDropdown = mousePos.X >= dropAbsPos.X and mousePos.X <= dropAbsPos.X + dropAbsSize.X
- and mousePos.Y >= dropAbsPos.Y and mousePos.Y <= dropAbsPos.Y + dropAbsSize.Y
- local btnAbsPos = dropdownButton.AbsolutePosition
- local btnAbsSize = dropdownButton.AbsoluteSize
- local inButton = mousePos.X >= btnAbsPos.X and mousePos.X <= btnAbsPos.X + btnAbsSize.X
- and mousePos.Y >= btnAbsPos.Y and mousePos.Y <= btnAbsPos.Y + btnAbsSize.Y
- if not inDropdown and not inButton then
- closeDropdown()
- end
- end
- end)
- end)
- actionButton.MouseButton1Click:Connect(function()
- if callback and selectedIndex and items[selectedIndex] then
- callback(items[selectedIndex], selectedIndex)
- end
- end)
- frame.Destroying:Connect(function()
- if inputConnection then
- inputConnection:Disconnect()
- inputConnection = nil
- end
- dropdownGui:Destroy()
- end)
- local dropdownObj = {}
- function dropdownObj:SetItems(newItems)
- items = newItems
- selectedIndex = (#items > 0) and 1 or nil
- dropdownButton.Text = items[selectedIndex] or "Select"
- refreshItems()
- end
- function dropdownObj:AddItem(item)
- table.insert(items, item)
- refreshItems()
- end
- function dropdownObj:SetButtonText(newText)
- actionButton.Text = newText
- end
- return dropdownObj
- end
- function Nex:Color(r, g, b)
- trackAPICall()
- if typeof(r) == "number" and typeof(g) == "number" and typeof(b) == "number" then
- accentColor = Color3.fromRGB(r, g, b)
- applyUITheme()
- else
- warn("Nex:Color expects three numbers (R, G, B).")
- end
- end
- function Nex:Font(fontEnum, size)
- trackAPICall()
- if typeof(fontEnum) == "EnumItem" and fontEnum.EnumType == Enum.Font then
- uiFont = fontEnum
- if typeof(size) == "number" then
- uiTextSize = size
- end
- applyUITheme()
- else
- warn("Nex:Font expects an Enum.Font and an optional number for size.")
- end
- end
- function Nex:addKeybind(title, toggleTitle, callback)
- trackAPICall()
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(1, -8, 0, 60)
- frame.BackgroundTransparency = 1
- frame.Parent = Container
- -- Label for the function
- local titleLabel = Instance.new("TextLabel")
- titleLabel.Text = tostring(title)
- titleLabel.Font = uiFont
- titleLabel.TextSize = uiTextSize
- titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- titleLabel.BackgroundTransparency = 1
- titleLabel.Size = UDim2.new(1, 0, 0, 18)
- titleLabel.TextXAlignment = Enum.TextXAlignment.Left
- titleLabel.Parent = frame
- -- Text box for keybind input
- local keybindTextBox = Instance.new("TextBox")
- keybindTextBox.PlaceholderText = "Click to set key..."
- keybindTextBox.Text = "[None]"
- keybindTextBox.Font = uiFont
- keybindTextBox.TextSize = uiTextSize
- keybindTextBox.TextColor3 = Color3.fromRGB(200, 200, 200)
- keybindTextBox.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- keybindTextBox.BorderSizePixel = 0
- keybindTextBox.Size = UDim2.new(0.6, 0, 0, 24)
- keybindTextBox.Position = UDim2.new(0, 0, 0, 20)
- keybindTextBox.TextXAlignment = Enum.TextXAlignment.Center
- keybindTextBox.ClearTextOnFocus = false
- keybindTextBox.Parent = frame
- createRounded(keybindTextBox, 5)
- -- Toggle (red/green slider)
- local toggleFrame = Instance.new("Frame")
- toggleFrame.Size = UDim2.new(0.3, 0, 0, 24)
- toggleFrame.Position = UDim2.new(0.65, 0, 0, 20)
- toggleFrame.BackgroundColor3 = Color3.fromRGB(255, 80, 80) -- Default OFF color (red)
- toggleFrame.BorderSizePixel = 0
- toggleFrame.Parent = frame
- createRounded(toggleFrame, 12)
- local toggleCircle = Instance.new("Frame")
- toggleCircle.Size = UDim2.new(0, 20, 1, 0)
- toggleCircle.Position = UDim2.new(0, 2, 0, 0) -- Left for OFF state
- toggleCircle.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- toggleCircle.BorderSizePixel = 0
- toggleCircle.Parent = toggleFrame
- createRounded(toggleCircle, 10)
- local toggleLabel = Instance.new("TextLabel")
- toggleLabel.Text = toggleTitle or "Enabled"
- toggleLabel.Font = uiFont
- toggleLabel.TextSize = uiTextSize - 2
- toggleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- toggleLabel.BackgroundTransparency = 1
- toggleLabel.Size = UDim2.new(1, 0, 1, 0)
- toggleLabel.TextXAlignment = Enum.TextXAlignment.Center
- toggleLabel.Parent = toggleFrame
- local isKeybindEnabled = false
- local currentKeybind = nil
- local inputConnection = nil
- local function updateToggleVisual()
- local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad)
- if isKeybindEnabled then
- TweenService:Create(toggleFrame, tweenInfo, {BackgroundColor3 = accentColor}):Play() -- ON color (accent)
- TweenService:Create(toggleCircle, tweenInfo, {Position = UDim2.new(1, -22, 0, 0)}):Play() -- Move right
- else
- TweenService:Create(toggleFrame, tweenInfo, {BackgroundColor3 = Color3.fromRGB(255, 80, 80)}):Play() -- OFF color (red)
- TweenService:Create(toggleCircle, tweenInfo, {Position = UDim2.new(0, 2, 0, 0)}):Play() -- Move left
- end
- end
- local function connectKeybind()
- if inputConnection then
- inputConnection:Disconnect()
- inputConnection = nil
- end
- if isKeybindEnabled and currentKeybind then
- inputConnection = UIS.InputBegan:Connect(function(input, gameProcessed)
- if not gameProcessed and input.KeyCode == currentKeybind then
- pcall(callback)
- end
- end)
- end
- end
- toggleFrame.MouseButton1Click:Connect(function()
- isKeybindEnabled = not isKeybindEnabled
- updateToggleVisual()
- connectKeybind()
- end)
- keybindTextBox.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- keybindTextBox.Text = "Press a key..."
- keybindTextBox.TextEditable = false
- local inputEndedConn
- inputEndedConn = UIS.InputEnded:Connect(function(inputFinished)
- if inputFinished.UserInputType == Enum.UserInputType.Keyboard then
- currentKeybind = inputFinished.KeyCode
- keybindTextBox.Text = currentKeybind.Name
- keybindTextBox.TextEditable = true
- connectKeybind()
- inputEndedConn:Disconnect()
- end
- end)
- end
- end)
- updateToggleVisual() -- Initial state
- connectKeybind() -- Initial connection for existing keybind (if any)
- return {
- SetKeybind = function(keyCode)
- if typeof(keyCode) == "EnumItem" and keyCode.EnumType == Enum.KeyCode then
- currentKeybind = keyCode
- keybindTextBox.Text = currentKeybind.Name
- connectKeybind()
- else
- warn("Nex:addKeybind:SetKeybind expects an Enum.KeyCode.")
- end
- },
- SetEnabled = function(enabled)
- if typeof(enabled) == "boolean" then
- isKeybindEnabled = enabled
- updateToggleVisual()
- connectKeybind()
- else
- warn("Nex:addKeybind:SetEnabled expects a boolean.")
- end
- },
- GetState = function()
- return isKeybindEnabled, currentKeybind
- end
- }
- end
- -- Initial application of the default theme
- applyUITheme()
- -- Demo Usage Script (auto-loads if no API calls are made)
- task.delay(0.1, function() -- Small delay to allow for immediate API calls
- if not apiCalled then
- Nex:SetTitle("NexusLib Demo")
- Nex:AddSection("Player Controls")
- Nex:AddButton("WalkSpeed to 50", function()
- player.Character.Humanoid.WalkSpeed = 50
- Nex:Notify("WalkSpeed set to 50!", 2, "S")
- end)
- local jumpToggle = Nex:AddToggle("AutoJump", {loop = true, loopdelay = 0.1}, function()
- if player.Character and player.Character.Humanoid then
- player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
- end
- end)
- Nex:AddButton("Toggle AutoJump", function()
- jumpToggle.Set(not jumpToggle.Get())
- Nex:Notify("AutoJump Toggled: " .. tostring(jumpToggle.Get()), 2, "D")
- end)
- local walkSpeedSlider = Nex:AddSlider("WalkSpeed", {min = 16, max = 100, default = 16}, function(value)
- if player.Character and player.Character.Humanoid then
- player.Character.Humanoid.WalkSpeed = value
- end
- Nex:Notify("WalkSpeed: " .. tostring(value), 1, "D")
- end)
- Nex:AddSection("Teleportation")
- local tpOptions = {"Spawn", "Mouse", "Opponent"}
- local dropdown = Nex:AddDropdown("Teleport To", tpOptions, "Teleport", function(selectedItem, index)
- if selectedItem == "Spawn" then
- player.Character:SetPrimaryPartCFrame(CFrame.new(game.Workspace.SpawnLocation.Position))
- Nex:Notify("Teleported to Spawn!", 2, "S")
- elseif selectedItem == "Mouse" then
- local mouse = player:GetMouse()
- if mouse.Hit then
- player.Character:SetPrimaryPartCFrame(mouse.Hit + Vector3.new(0, 3, 0))
- Nex:Notify("Teleported to Mouse!", 2, "S")
- else
- Nex:Notify("Invalid mouse target!", 2, "E")
- end
- elseif selectedItem == "Opponent" then
- local enemies = {}
- for _, p in pairs(Players:GetPlayers()) do
- if p.Name ~= player.Name and p.Character and p.Character:FindFirstChildOfClass("Humanoid") then
- table.insert(enemies, p.Character.HumanoidRootPart.Position)
- end
- end
- if #enemies > 0 then
- local randomEnemyPos = enemies[math.random(1, #enemies)]
- player.Character:SetPrimaryPartCFrame(CFrame.new(randomEnemyPos + Vector3.new(0, 3, 0)))
- Nex:Notify("Teleported to opponent!", 2, "S")
- else
- Nex:Notify("No opponents found!", 2, "E")
- end
- end
- end)
- Nex:AddSection("Theme Settings")
- Nex:AddButton("Change Accent Color (Red)", function()
- Nex:Color(255, 0, 0)
- Nex:Notify("Accent Color set to Red!", 2, "S")
- end)
- Nex:AddButton("Change Accent Color (Green)", function()
- Nex:Color(0, 255, 0)
- Nex:Notify("Accent Color set to Green!", 2, "S")
- end)
- local keybind = Nex:addKeybind("Toggle Noclip", "Noclip Enabled", function()
- -- Simple Noclip Toggle (requires character and humanoid)
- if player.Character and player.Character.Humanoid then
- local humanoid = player.Character.Humanoid
- humanoid.WalkSpeed = (humanoid.WalkSpeed == 0) and 16 or 0
- for _, part in ipairs(player.Character:GetDescendants()) do
- if part:IsA("BasePart") then
- part.CanCollide = not part.CanCollide
- end
- end
- Nex:Notify("Noclip Toggled!", 1.5, "D")
- else
- Nex:Notify("Noclip requires a character!", 1.5, "E")
- end
- })
- keybind.SetKeybind(Enum.KeyCode.Q) -- Default keybind to 'Q'
- Nex:Notify("NexusLib Demo Loaded!", 3, "S")
- end
- end)
- return Nex
Advertisement
Add Comment
Please, Sign In to add comment