Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UILibrary = {}
- UILibrary.__index = UILibrary
- function UILibrary.new(title)
- local self = setmetatable({}, UILibrary)
- local existingGui = game:GetService("CoreGui"):FindFirstChild("UILibrary")
- if existingGui then
- existingGui:Destroy()
- end
- self.screenGui = Instance.new("ScreenGui")
- self.screenGui.Name = "UILibrary"
- self.screenGui.Parent = game:GetService("CoreGui")
- self.mainFrame = Instance.new("Frame")
- self.mainFrame.Parent = self.screenGui
- self.mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- self.mainFrame.Size = UDim2.new(0, 600, 0, 360)
- self.mainFrame.Position = UDim2.new(0.5, -295, 0.5, -211)
- self.mainFrame.BorderSizePixel = 0
- self.mainFrame.BackgroundTransparency = 0
- self.titleBar = Instance.new("TextLabel")
- self.titleBar.Parent = self.mainFrame
- self.titleBar.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- self.titleBar.Size = UDim2.new(1, 0, 0, 30)
- self.titleBar.Text = title or ""
- self.titleBar.TextColor3 = Color3.fromRGB(255, 255, 255)
- self.titleBar.Font = Enum.Font.SourceSans
- self.titleBar.TextSize = 20
- self.titleBar.BorderSizePixel = 0
- self.titleBar.BackgroundTransparency = 0
- self.closeButton = Instance.new("TextButton")
- self.closeButton.Parent = self.titleBar
- self.closeButton.Text = "X"
- self.closeButton.Size = UDim2.new(0, 30, 1, 0)
- self.closeButton.Position = UDim2.new(1, -30, 0, 0)
- self.closeButton.BorderSizePixel = 0
- self.closeButton.Font = Enum.Font.SourceSans
- self.closeButton.TextSize = 20
- self.closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- self.closeButton.BackgroundTransparency = 1
- self.closeButton.MouseButton1Click:Connect(function()
- self:Destroy()
- end)
- self.minimizeButton = Instance.new("TextButton")
- self.minimizeButton.Parent = self.titleBar
- self.minimizeButton.Text = "-"
- self.minimizeButton.Size = UDim2.new(0, 30, 1, 0)
- self.minimizeButton.Position = UDim2.new(1, -60, 0, 0)
- self.minimizeButton.BorderSizePixel = 0
- self.minimizeButton.Font = Enum.Font.SourceSans
- self.minimizeButton.TextSize = 20
- self.minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- self.minimizeButton.BackgroundTransparency = 1
- self.isMinimized = false
- self.minimizeButton.MouseButton1Click:Connect(function()
- if self.isMinimized then
- self.mainFrame.Size = UDim2.new(0, 600, 0, 360)
- self.isMinimized = false
- else
- self.mainFrame.Size = UDim2.new(0, 600, 0, 30)
- self.isMinimized = true
- end
- end)
- self.tabFrame = Instance.new("Frame")
- self.tabFrame.Parent = self.mainFrame
- self.tabFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- self.tabFrame.Size = UDim2.new(0, 150, 1, -30)
- self.tabFrame.Position = UDim2.new(0, 0, 0, 30)
- self.tabFrame.BorderSizePixel = 0
- local tabLayout = Instance.new("UIListLayout", self.tabFrame)
- tabLayout.Padding = UDim.new(0, 5)
- tabLayout.SortOrder = Enum.SortOrder.LayoutOrder
- self.contentFrame = Instance.new("Frame")
- self.contentFrame.Parent = self.mainFrame
- self.contentFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
- self.contentFrame.Size = UDim2.new(1, -150, 1, -30)
- self.contentFrame.Position = UDim2.new(0, 150, 0, 30)
- self.contentFrame.BorderSizePixel = 0
- local contentLayout = Instance.new("UIListLayout", self.contentFrame)
- contentLayout.Padding = UDim.new(0, 10)
- contentLayout.SortOrder = Enum.SortOrder.LayoutOrder
- local TweenService = game:GetService("TweenService")
- local dragging = false
- local dragStart = nil
- local startPos = nil
- local function smoothMove(frame, targetPosition)
- local tween = TweenService:Create(
- frame,
- TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
- {Position = targetPosition}
- )
- tween:Play()
- end
- local function update(input)
- local delta = input.Position - dragStart
- local newPos = UDim2.new(
- startPos.X.Scale,
- startPos.X.Offset + delta.X,
- startPos.Y.Scale,
- startPos.Y.Offset + delta.Y
- )
- smoothMove(self.mainFrame, newPos)
- end
- self.titleBar.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- dragStart = input.Position
- startPos = self.mainFrame.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- self.titleBar.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- if dragging then
- update(input)
- end
- end
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)
- if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
- update(input)
- end
- end)
- return self
- end
- function UILibrary:Destroy()
- if self.screenGui then
- self.screenGui:Destroy()
- end
- end
- function UILibrary:CreateTab(tabName)
- local button = Instance.new("TextButton")
- button.Parent = self.tabFrame
- button.Text = tabName
- button.Size = UDim2.new(1, -10, 0, 40)
- button.Position = UDim2.new(0, 5, 0, 0)
- button.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- button.TextColor3 = Color3.fromRGB(255, 255, 255)
- button.Font = Enum.Font.SourceSans
- button.TextSize = 18
- local tabContent = Instance.new("Frame")
- tabContent.Name = tabName
- tabContent.Visible = false
- tabContent.Size = UDim2.new(1, 0, 1, 0)
- tabContent.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
- tabContent.BorderSizePixel = 0
- tabContent.Parent = self.contentFrame
- local layout = Instance.new("UIListLayout", tabContent)
- layout.Padding = UDim.new(0, 10)
- layout.SortOrder = Enum.SortOrder.LayoutOrder
- button.MouseButton1Click:Connect(function()
- for _, tab in ipairs(self.contentFrame:GetChildren()) do
- if tab:IsA("Frame") then
- tab.Visible = tab == tabContent
- end
- end
- end)
- if #self.tabFrame:GetChildren() == 1 then
- button.MouseButton1Click:Fire()
- end
- return tabContent
- end
- function UILibrary:CreateButton(parent, text, callback)
- local button = Instance.new("TextButton")
- button.Parent = parent
- button.Text = text
- button.Size = UDim2.new(1, 0, 0, 40)
- button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
- button.TextColor3 = Color3.fromRGB(255, 255, 255)
- button.Font = Enum.Font.SourceSans
- button.TextSize = 18
- button.BorderSizePixel = 0
- button.MouseButton1Click:Connect(function()
- callback()
- end)
- return button
- end
- function UILibrary:CreateToggle(parent, text, default, callback)
- local toggleFrame = Instance.new("Frame", parent)
- toggleFrame.Size = UDim2.new(1, -20, 0, 40)
- toggleFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- local toggleLabel = Instance.new("TextLabel", toggleFrame)
- toggleLabel.Size = UDim2.new(0, 200, 1, 0)
- toggleLabel.Text = text
- toggleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- toggleLabel.BackgroundTransparency = 1
- toggleLabel.TextSize = 18
- toggleLabel.Font = Enum.Font.SourceSans
- local button = Instance.new("TextButton", toggleFrame)
- button.Size = UDim2.new(0, 60, 0, 30)
- button.Position = UDim2.new(1, -65, 0, 5)
- button.Text = default and "ON" or "OFF"
- button.BackgroundColor3 = default and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
- button.TextColor3 = Color3.fromRGB(255, 255, 255)
- button.Font = Enum.Font.SourceSans
- button.TextSize = 18
- button.MouseButton1Click:Connect(function()
- default = not default
- button.Text = default and "ON" or "OFF"
- button.BackgroundColor3 = default and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
- if callback then callback(default) end
- end)
- return toggleFrame
- end
- function UILibrary:CreateSlider(parent, text, minValue, maxValue, callback)
- local sliderFrame = Instance.new("Frame", parent)
- sliderFrame.Size = UDim2.new(1, -20, 0, 40)
- sliderFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- local label = Instance.new("TextLabel", sliderFrame)
- label.Text = text
- label.Size = UDim2.new(0.4, 0, 1, 0)
- label.BackgroundTransparency = 1
- label.TextColor3 = Color3.fromRGB(255, 255, 255)
- label.Font = Enum.Font.SourceSans
- label.TextSize = 18
- local sliderBar = Instance.new("Frame", sliderFrame)
- sliderBar.Size = UDim2.new(0.5, -10, 0, 5)
- sliderBar.Position = UDim2.new(0.5, 0, 0.5, -2)
- sliderBar.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
- sliderBar.BorderSizePixel = 0
- local sliderThumb = Instance.new("TextButton", sliderBar)
- sliderThumb.Size = UDim2.new(0, 20, 1, 0)
- sliderThumb.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- sliderThumb.Text = ""
- sliderThumb.BorderSizePixel = 0
- local valueLabel = Instance.new("TextLabel", sliderFrame)
- valueLabel.Size = UDim2.new(0.2, 0, 1, 0)
- valueLabel.Position = UDim2.new(0.8, 0, 0, 0)
- valueLabel.BackgroundTransparency = 1
- valueLabel.Text = tostring(minValue)
- valueLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- valueLabel.Font = Enum.Font.SourceSans
- valueLabel.TextSize = 18
- local dragging = false
- local function updateSlider(input)
- if dragging then
- local position = math.clamp((input.Position.X - sliderBar.AbsolutePosition.X) / sliderBar.AbsoluteSize.X, 0, 1)
- sliderThumb.Position = UDim2.new(position, -10, 0, 0)
- local value = math.floor(minValue + (maxValue - minValue) * position)
- valueLabel.Text = tostring(value)
- if callback then callback(value) end
- end
- end
- sliderThumb.MouseButton1Down:Connect(function()
- dragging = true
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- updateSlider(input)
- end
- end)
- game:GetService("UserInputService").InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = false
- end
- end)
- return sliderFrame
- end
- function UILibrary:CreateDropdown(parent, text, options, callback)
- local dropdownFrame = Instance.new("Frame", parent)
- dropdownFrame.Size = UDim2.new(1, -20, 0, 40)
- dropdownFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- dropdownFrame.ZIndex = 2 -- Aseguramos que esté por encima de GUIs básicos
- local label = Instance.new("TextLabel", dropdownFrame)
- label.Text = text
- label.Size = UDim2.new(0.7, 0, 1, 0)
- label.BackgroundTransparency = 1
- label.TextColor3 = Color3.fromRGB(255, 255, 255)
- label.Font = Enum.Font.SourceSans
- label.TextSize = 18
- label.ZIndex = 2 -- También ajustamos el ZIndex de los hijos
- local button = Instance.new("TextButton", dropdownFrame)
- button.Text = "▼"
- button.Size = UDim2.new(0.3, 0, 1, 0)
- button.Position = UDim2.new(0.7, 0, 0, 0)
- button.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- button.TextColor3 = Color3.fromRGB(255, 255, 255)
- button.Font = Enum.Font.SourceSans
- button.TextSize = 18
- button.ZIndex = 2
- local optionsFrame = Instance.new("Frame", dropdownFrame)
- optionsFrame.Size = UDim2.new(1, 0, 0, 0)
- optionsFrame.Position = UDim2.new(0, 0, 1, 0)
- optionsFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
- optionsFrame.Visible = false
- optionsFrame.ZIndex = 3 -- Aseguramos que esté por encima de dropdownFrame
- local layout = Instance.new("UIListLayout", optionsFrame)
- layout.Padding = UDim.new(0, 5)
- for _, option in ipairs(options) do
- local optionButton = Instance.new("TextButton", optionsFrame)
- optionButton.Text = option
- optionButton.Size = UDim2.new(1, 0, 0, 30)
- optionButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- optionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- optionButton.Font = Enum.Font.SourceSans
- optionButton.TextSize = 18
- optionButton.ZIndex = 3
- optionButton.MouseButton1Click:Connect(function()
- if callback then callback(option) end
- optionsFrame.Visible = false
- end)
- end
- button.MouseButton1Click:Connect(function()
- optionsFrame.Visible = not optionsFrame.Visible
- end)
- return dropdownFrame
- end
- function UILibrary:CreateParagraph(parent, text)
- local paragraph = Instance.new("TextLabel")
- paragraph.Text = text
- paragraph.TextColor3 = Color3.fromRGB(255, 255, 255)
- paragraph.Size = UDim2.new(1, -20, 0, 60)
- paragraph.BackgroundTransparency = 1
- paragraph.TextSize = 18
- paragraph.TextWrapped = true
- paragraph.TextXAlignment = Enum.TextXAlignment.Left
- paragraph.Parent = parent
- return paragraph
- end
- function UILibrary:CreateSection(parent, title)
- local sectionFrame = Instance.new("Frame")
- sectionFrame.Size = UDim2.new(1, 0, 0, 50)
- sectionFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- sectionFrame.Parent = parent
- local sectionLabel = Instance.new("TextLabel")
- sectionLabel.Text = title
- sectionLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- sectionLabel.Size = UDim2.new(1, 0, 1, 0)
- sectionLabel.BackgroundTransparency = 1
- sectionLabel.Font = Enum.Font.SourceSans
- sectionLabel.TextSize = 20
- sectionLabel.TextXAlignment = Enum.TextXAlignment.Center
- sectionLabel.Parent = sectionFrame
- return sectionFrame
- end
- function UILibrary:ButtonToggle(properties)
- local toggleButton = Instance.new("ImageButton")
- toggleButton.Image = properties.Image or "rbxassetid://17888450855"
- toggleButton.Size = properties.Size or UDim2.new(0, 40, 0, 40)
- toggleButton.Position = properties.Position or UDim2.new(0, 10, 0, 10)
- toggleButton.BackgroundTransparency = properties.BackgroundTransparency or 1
- toggleButton.ImageTransparency = properties.ImageTransparency or 0
- if properties.CornerRadius then
- local corner = Instance.new("UICorner", toggleButton)
- corner.CornerRadius = properties.CornerRadius
- end
- toggleButton.Parent = self.screenGui
- local isVisible = true
- local dragging = false
- local dragStart, startPos
- local function startDrag(input)
- dragging = true
- dragStart = input.Position
- startPos = toggleButton.Position
- end
- local function updateDrag(input)
- if dragging then
- local delta = input.Position - dragStart
- toggleButton.Position = UDim2.new(
- startPos.X.Scale, startPos.X.Offset + delta.X,
- startPos.Y.Scale, startPos.Y.Offset + delta.Y
- )
- end
- end
- local function endDrag()
- dragging = false
- end
- toggleButton.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- startDrag(input)
- end
- end)
- toggleButton.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- updateDrag(input)
- end
- end)
- toggleButton.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- endDrag()
- end
- end)
- toggleButton.MouseButton1Click:Connect(function()
- if not dragging then
- isVisible = not isVisible
- if self.mainFrame then
- self.mainFrame.Visible = isVisible
- end
- end
- end)
- return toggleButton
- end
- return UILibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement