Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CustomUI UI Library
- -- Generated by UI Library Generator
- -- Features: draggable, animations, responsive, rounded
- -- Components: button, toggle, slider, dropdown, textbox, notification, tabs
- -- CustomUI Library Implementation
- local CustomUI = {}
- -- Function to create a new UI element
- function CustomUI.new()
- local self = {}
- -- Theme Settings
- local theme = {
- background = Color3.fromRGB(30, 30, 30),
- textColor = Color3.fromRGB(255, 255, 255),
- buttonColor = Color3.fromRGB(50, 50, 255),
- buttonHoverColor = Color3.fromRGB(70, 70, 255)
- }
- -- Create the notification system
- function self:notification(type, message, duration)
- local types = {
- success = Color3.fromRGB(0, 255, 0),
- error = Color3.fromRGB(255, 0, 0),
- info = Color3.fromRGB(0, 0, 255)
- }
- local notification = Instance.new('TextLabel')
- notification.BackgroundColor3 = types[type] or Color3.fromRGB(255, 255, 255)
- notification.TextColor3 = theme.textColor
- notification.Text = message
- notification.Size = UDim2.new(0, 300, 0, 50)
- notification.Position = UDim2.new(0.5, -150, 0, 10)
- notification.AnchorPoint = Vector2.new(0.5, 0)
- notification.Parent = game.Players.LocalPlayer:WaitForChild('PlayerGui')
- wait(duration or 3)
- notification:Destroy()
- end
- -- Button Component
- function self:button(text, callback)
- local button = Instance.new('TextButton')
- button.Text = text
- button.BackgroundColor3 = theme.buttonColor
- button.TextColor3 = theme.textColor
- button.Size = UDim2.new(0, 100, 0, 50)
- button.MouseButton1Click:Connect(function() callback() end)
- button.MouseEnter:Connect(function()
- button.BackgroundColor3 = theme.buttonHoverColor
- end)
- button.MouseLeave:Connect(function()
- button.BackgroundColor3 = theme.buttonColor
- end)
- return button
- end
- -- Toggle Component
- function self:toggle(text, callback)
- local toggle = Instance.new('TextButton')
- toggle.Text = text
- toggle.BackgroundColor3 = theme.buttonColor
- toggle.TextColor3 = theme.textColor
- toggle.Size = UDim2.new(0, 100, 0, 50)
- local isToggled = false
- toggle.MouseButton1Click:Connect(function()
- isToggled = not isToggled
- toggle.BackgroundColor3 = isToggled and Color3.fromRGB(0, 255, 0) or theme.buttonColor
- callback(isToggled)
- end)
- return toggle
- end
- -- Slider Component
- function self:slider(min, max, callback)
- local slider = Instance.new('Frame')
- slider.Size = UDim2.new(0, 200, 0, 50)
- local sliderButton = Instance.new('TextButton')
- sliderButton.Size = UDim2.new(0, 10, 1, 0)
- sliderButton.BackgroundColor3 = theme.buttonColor
- local value = min
- sliderButton.MouseDrag:Connect(function()
- local mouse = game.Players.LocalPlayer:GetMouse()
- local position = math.clamp(mouse.X - slider.AbsolutePosition.X, 0, slider.AbsoluteSize.X)
- value = math.floor((position / slider.AbsoluteSize.X) * (max - min)) + min
- callback(value)
- end)
- sliderButton.Parent = slider
- return slider
- end
- -- Dropdown Component
- function self:dropdown(items, callback)
- local dropdown = Instance.new('Frame')
- dropdown.Size = UDim2.new(0, 200, 0, 50)
- local isOpen = false
- local dropdownButton = Instance.new('TextButton')
- dropdownButton.Text = "Select an option"
- dropdownButton.Size = UDim2.new(1, 0, 1, 0)
- dropdownButton.Parent = dropdown
- dropdownButton.MouseButton1Click:Connect(function()
- isOpen = not isOpen
- -- Implementation of dropdown options
- end)
- return dropdown
- end
- -- Textbox Component
- function self:textbox(placeholder, callback)
- local textbox = Instance.new('TextBox')
- textbox.Text = ""
- textbox.PlaceholderText = placeholder
- textbox.Size = UDim2.new(0, 200, 0, 50)
- textbox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- callback(textbox.Text)
- end
- end)
- return textbox
- end
- -- Tabs Component
- function self:tabs(tabList)
- local tabContainer = Instance.new('Frame')
- tabContainer.Size = UDim2.new(1, 0, 1, 0)
- local currentTab
- for _, tab in ipairs(tabList) do
- local tabButton = Instance.new('TextButton')
- tabButton.Text = tab.name
- tabButton.Size = UDim2.new(0, 100, 0, 50)
- tabButton.Parent = tabContainer
- tabButton.MouseButton1Click:Connect(function()
- if currentTab then
- currentTab.Visible = false
- end
- currentTab = tab.content
- currentTab.Visible = true
- end)
- end
- return tabContainer
- end
- -- UICorner for rounded corners
- function self:applyUICorner(element)
- local corner = Instance.new('UICorner')
- corner.CornerRadius = UDim.new(0, 10)
- corner.Parent = element
- end
- return self
- end
- return CustomUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement