Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- UI Lib
- local UILib = {}
- -- Função para permitir que um Frame seja arrastável com mouse ou toque
- local function MakeDraggable(frame, dragHandle)
- local dragging
- local dragInput
- local dragStart
- local startPos
- local function Update(input)
- local delta = input.Position - dragStart
- frame.Position = UDim2.new(
- startPos.X.Scale,
- startPos.X.Offset + delta.X,
- startPos.Y.Scale,
- startPos.Y.Offset + delta.Y
- )
- end
- dragHandle.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- dragStart = input.Position
- startPos = frame.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- dragHandle.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- dragInput = input
- end
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)
- if input == dragInput and dragging then
- Update(input)
- end
- end)
- end
- -- Função para criar uma janela (window) com cantos arredondados
- function UILib:CreateWindow(title)
- local ScreenGui = Instance.new("ScreenGui")
- local MainFrame = Instance.new("Frame")
- local TitleLabel = Instance.new("TextLabel")
- local MinimizeButton = Instance.new("TextButton")
- local CloseButton = Instance.new("TextButton")
- local UICornerMain = Instance.new("UICorner")
- local UICornerButton = Instance.new("UICorner")
- -- Propriedades do ScreenGui
- ScreenGui.Name = "UILib"
- ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- ScreenGui.ResetOnSpawn = false
- -- Propriedades da MainFrame (largura aumentada)
- MainFrame.Name = "MainFrame"
- MainFrame.Parent = ScreenGui
- MainFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
- MainFrame.Position = UDim2.new(0.2, 0, 0.3, 0)
- MainFrame.Size = UDim2.new(0, 600, 0, 300) -- Interface mais larga
- -- Propriedades do UICorner (arredondando a janela)
- UICornerMain.Parent = MainFrame
- UICornerMain.CornerRadius = UDim.new(0, 12)
- -- Propriedades do Título
- TitleLabel.Name = "TitleLabel"
- TitleLabel.Parent = MainFrame
- TitleLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- TitleLabel.BackgroundTransparency = 1
- TitleLabel.Position = UDim2.new(0, 0, 0, 0)
- TitleLabel.Size = UDim2.new(1, 0, 0, 50)
- TitleLabel.Font = Enum.Font.Custom
- TitleLabel.Text = title or "New Window"
- TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- TitleLabel.TextSize = 24
- TitleLabel.FontFace = Font.fromId(12187371840) -- Fonte customizada
- -- Botão de minimizar no canto superior direito
- MinimizeButton.Name = "MinimizeButton"
- MinimizeButton.Parent = MainFrame
- MinimizeButton.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
- MinimizeButton.Position = UDim2.new(1, -80, 0, 10)
- MinimizeButton.Size = UDim2.new(0, 30, 0, 30)
- MinimizeButton.Font = Enum.Font.Custom
- MinimizeButton.Text = "-"
- MinimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- MinimizeButton.TextSize = 20
- MinimizeButton.FontFace = Font.fromId(12187371840)
- -- Botão de fechar no canto superior direito
- CloseButton.Name = "CloseButton"
- CloseButton.Parent = MainFrame
- CloseButton.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
- CloseButton.Position = UDim2.new(1, -40, 0, 10)
- CloseButton.Size = UDim2.new(0, 30, 0, 30)
- CloseButton.Font = Enum.Font.Custom
- CloseButton.Text = "×"
- CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- CloseButton.TextSize = 20
- CloseButton.FontFace = Font.fromId(12187371840)
- -- Aplicando cantos arredondados nos botões de minimizar e fechar
- local UICornerMinimize = Instance.new("UICorner")
- UICornerMinimize.CornerRadius = UDim.new(0, 6)
- UICornerMinimize.Parent = MinimizeButton
- local UICornerClose = Instance.new("UICorner")
- UICornerClose.CornerRadius = UDim.new(0, 6)
- UICornerClose.Parent = CloseButton
- -- Funções para minimizar e fechar a janela
- MinimizeButton.MouseButton1Click:Connect(function()
- MainFrame.Visible = not MainFrame.Visible
- end)
- CloseButton.MouseButton1Click:Connect(function()
- ScreenGui:Destroy()
- end)
- -- Tornar o Frame "draggable" com mouse e toque
- MakeDraggable(MainFrame, TitleLabel)
- return {
- Frame = MainFrame
- }
- end
- -- Função para criar botões menores e com cantos arredondados na janela
- function UILib:CreateButton(window, buttonText, callback)
- local Button = Instance.new("TextButton")
- local UICornerButton = Instance.new("UICorner")
- -- Propriedades do Button (botões menores, alinhados à esquerda)
- Button.Name = "Button"
- Button.Parent = window.Frame
- Button.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
- Button.Size = UDim2.new(0, 150, 0, 40) -- Botões menores
- Button.Position = UDim2.new(0, 10, 0, 60) -- Botões à esquerda
- Button.Font = Enum.Font.Custom
- Button.Text = buttonText or "Button"
- Button.TextColor3 = Color3.fromRGB(255, 255, 255)
- Button.TextSize = 20
- Button.FontFace = Font.fromId(12187371840) -- Fonte customizada
- -- Propriedades do UICorner (para arredondar os cantos do botão)
- UICornerButton.Parent = Button
- UICornerButton.CornerRadius = UDim.new(0, 10)
- Button.MouseButton1Click:Connect(function()
- pcall(callback)
- end)
- return Button
- end
- return UILib
Advertisement
Add Comment
Please, Sign In to add comment