Untitled

Run Settings
LanguageLua
Language Version
Run Command
local GUILibrary = {} GUILibrary.__index = GUILibrary -- Конфигурация по умолчанию GUILibrary.defaultConfig = { name = "CustomGUI", size = UDim2.new(0, 200, 0, 300), position = UDim2.new(0.5, -100, 0.5, -150), backgroundColor = Color3.fromRGB(40, 40, 40), backgroundTransparency = 0.3, cornerRadius = 8, textColor = Color3.new(1, 1, 1), buttonColor = Color3.fromRGB(60, 60, 60), activeButtonColor = Color3.fromRGB(80, 20, 20), font = Enum.Font.Gotham, titleFont = Enum.Font.GothamBold, textSize = 14, titleTextSize = 18 } function GUILibrary.new(config) local self = setmetatable({}, GUILibrary) self.config = setmetatable(config or {}, {__index = GUILibrary.defaultConfig}) self.elements = {} self.connections = {} self.isMinimized = false self.isPhase2 = false -- Создаем основной GUI self:createMainGUI() return self end function GUILibrary:createMainGUI() -- Основной экран GUI self.screenGui = Instance.new("ScreenGui") self.screenGui.Name = self.config.name self.screenGui.Parent = game:GetService("CoreGui") -- Основной фрейм self.mainFrame = Instance.new("Frame") self.mainFrame.Size = self.config.size self.mainFrame.Position = self.config.position self.mainFrame.BackgroundColor3 = self.config.backgroundColor self.mainFrame.BackgroundTransparency = self.config.backgroundTransparency self.mainFrame.Parent = self.screenGui self.mainFrame.Active = true self.mainFrame.Draggable = true local UICorner = Instance.new("UICorner") UICorner.CornerRadius = UDim.new(0, self.config.cornerRadius) UICorner.Parent = self.mainFrame -- Заголовок self.title = Instance.new("TextLabel") self.title.Size = UDim2.new(1, 0, 0, 30) self.title.Position = UDim2.new(0, 0, 0, 5) self.title.BackgroundTransparency = 1 self.title.Text = self.config.name self.title.TextColor3 = self.config.textColor self.title.Font = self.config.titleFont self.title.TextSize = self.config.titleTextSize self.title.Parent = self.mainFrame -- Кнопки управления self:createControlButtons() -- Сохраняем оригинальный размер для минимизации self.originalSize = self.mainFrame.Size self.originalTitle = self.title.Text end function GUILibrary:createControlButtons() -- Кнопка сворачивания self.toggleMinimizeBtn = self:createButton("-", UDim2.new(1, -25, 0, 5), UDim2.new(0, 20, 0, 20)) self.toggleMinimizeBtn.MouseButton1Click:Connect(function() self:toggleMinimize() end) -- Кнопка переключения фаз self.togglePhaseBtn = self:createButton("1", UDim2.new(0, 5, 0, 5), UDim2.new(0, 20, 0, 20)) self.togglePhaseBtn.MouseButton1Click:Connect(function() self:togglePhase() end) -- Невидимая кнопка для разворачивания self.invisibleExpandBtn = Instance.new("TextButton") self.invisibleExpandBtn.Size = UDim2.new(1, 0, 1, 0) self.invisibleExpandBtn.Position = UDim2.new(0, 0, 0, 0) self.invisibleExpandBtn.BackgroundTransparency = 1 self.invisibleExpandBtn.Text = "" self.invisibleExpandBtn.TextTransparency = 1 self.invisibleExpandBtn.Visible = false self.invisibleExpandBtn.Parent = self.mainFrame self.invisibleExpandBtn.MouseButton1Click:Connect(function() if self.isMinimized then self:toggleMinimize() end end) end -- Основные методы управления GUI function GUILibrary:toggleMinimize() self.isMinimized = not self.isMinimized if self.isMinimized then -- Скрываем все элементы for _, element in pairs(self.elements) do if element.instance then element.instance.Visible = false end end -- Минимизируем GUI self.mainFrame.Size = UDim2.new(0, 60, 0, 30) self.title.Text = string.sub(self.config.name, 1, 3) self.title.Size = UDim2.new(1, 0, 1, 0) self.title.Position = UDim2.new(0, 0, 0, 0) self.toggleMinimizeBtn.Visible = false self.togglePhaseBtn.Visible = false self.invisibleExpandBtn.Visible = true else -- Восстанавливаем GUI self.mainFrame.Size = self.originalSize self.title.Text = self.originalTitle self.title.Size = UDim2.new(1, 0, 0, 30) self.title.Position = UDim2.new(0, 0, 0, 5) self.toggleMinimizeBtn.Visible = true self.togglePhaseBtn.Visible = true self.invisibleExpandBtn.Visible = false -- Показываем элементы в зависимости от фазы for _, element in pairs(self.elements) do if element.instance then element.instance.Visible = not element.phase or (element.phase == 1 and not self.isPhase2) or (element.phase == 2 and self.isPhase2) end end end end function GUILibrary:togglePhase() self.isPhase2 = not self.isPhase2 self.togglePhaseBtn.Text = self.isPhase2 and "2" or "1" -- Показываем/скрываем элементы в зависимости от фазы for _, element in pairs(self.elements) do if element.instance then element.instance.Visible = not element.phase or (element.phase == 1 and not self.isPhase2) or (element.phase == 2 and self.isPhase2) end end end -- Методы для создания элементов GUI function GUILibrary:createButton(text, position, size, options) options = options or {} local button = Instance.new("TextButton") button.Size = size or UDim2.new(0.9, 0, 0, 30) button.Position = position or UDim2.new(0.05, 0, 0, 40) button.BackgroundColor3 = options.buttonColor or self.config.buttonColor button.Text = text or "Button" button.TextColor3 = options.textColor or self.config.textColor button.Font = options.font or self.config.font button.TextSize = options.textSize or self.config.textSize button.Parent = self.mainFrame button.Visible = not options.phase or (options.phase == 1 and not self.isPhase2) or (options.phase == 2 and self.isPhase2) local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, options.cornerRadius or 6) corner.Parent = button -- Сохраняем элемент для управления видимостью table.insert(self.elements, { instance = button, phase = options.phase }) return button end function GUILibrary:createTextBox(placeholder, position, size, options) options = options or {} local textBox = Instance.new("TextBox") textBox.Size = size or UDim2.new(0.9, 0, 0, 30) textBox.Position = position or UDim2.new(0.05, 0, 0, 40) textBox.BackgroundColor3 = options.backgroundColor or Color3.fromRGB(30, 30, 30) textBox.Text = options.text or "" textBox.PlaceholderText = placeholder or "" textBox.TextColor3 = options.textColor or self.config.textColor textBox.ClearTextOnFocus = options.clearOnFocus or false textBox.Parent = self.mainFrame textBox.Visible = not options.phase or (options.phase == 1 and not self.isPhase2) or (options.phase == 2 and self.isPhase2) local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, options.cornerRadius or 6) corner.Parent = textBox table.insert(self.elements, { instance = textBox, phase = options.phase }) return textBox end function GUILibrary:createLabel(text, position, size, options) options = options or {} local label = Instance.new("TextLabel") label.Size = size or UDim2.new(1, 0, 0, 20) label.Position = position or UDim2.new(0, 0, 0, 280) label.BackgroundTransparency = 1 label.Text = text or "Label" label.TextColor3 = options.textColor or self.config.textColor label.Font = options.font or self.config.font label.TextSize = options.textSize or self.config.textSize label.Parent = self.mainFrame label.Visible = not options.phase or (options.phase == 1 and not self.isPhase2) or (options.phase == 2 and self.isPhase2) table.insert(self.elements, { instance = label, phase = options.phase }) return label end function GUILibrary:createSlider(minValue, maxValue, defaultValue, position, size, options) options = options or {} local sliderFrame = Instance.new("Frame") sliderFrame.Size = size or UDim2.new(0.9, 0, 0, 50) sliderFrame.Position = position or UDim2.new(0.05, 0, 0, 80) sliderFrame.BackgroundTransparency = 1 sliderFrame.Parent = self.mainFrame sliderFrame.Visible = not options.phase or (options.phase == 1 and not self.isPhase2) or (options.phase == 2 and self.isPhase2) local sliderLabel = Instance.new("TextLabel") sliderLabel.Size = UDim2.new(1, 0, 0, 20) sliderLabel.Position = UDim2.new(0, 0, 0, 0) sliderLabel.BackgroundTransparency = 1 sliderLabel.Text = options.label or "Slider" sliderLabel.TextColor3 = options.textColor or self.config.textColor sliderLabel.Font = options.font or self.config.font sliderLabel.TextSize = options.textSize or self.config.textSize sliderLabel.Parent = sliderFrame local sliderTrack = Instance.new("Frame") sliderTrack.Size = UDim2.new(1, 0, 0, 10) sliderTrack.Position = UDim2.new(0, 0, 0, 25) sliderTrack.BackgroundColor3 = Color3.fromRGB(60, 60, 60) sliderTrack.Parent = sliderFrame local sliderFill = Instance.new("Frame") sliderFill.Size = UDim2.new(0, 0, 1, 0) sliderFill.Position = UDim2.new(0, 0, 0, 0) sliderFill.BackgroundColor3 = options.fillColor or Color3.fromRGB(80, 20, 20) sliderFill.Parent = sliderTrack local sliderThumb = Instance.new("TextButton") sliderThumb.Size = UDim2.new(0, 20, 0, 20) sliderThumb.Position = UDim2.new(0, -10, 0, -5) sliderThumb.BackgroundColor3 = options.thumbColor or Color3.fromRGB(100, 100, 100) sliderThumb.Text = "" sliderThumb.Parent = sliderTrack local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 4) corner.Parent = sliderTrack corner:Clone().Parent = sliderFill corner:Clone().Parent = sliderThumb local valueLabel = Instance.new("TextLabel") valueLabel.Size = UDim2.new(1, 0, 0, 20) valueLabel.Position = UDim2.new(0, 0, 0, 35) valueLabel.BackgroundTransparency = 1 valueLabel.Text = tostring(defaultValue or minValue) valueLabel.TextColor3 = options.textColor or self.config.textColor valueLabel.Font = options.font or self.config.font valueLabel.TextSize = options.textSize or self.config.textSize valueLabel.Parent = sliderFrame -- Логика слайдера local isDragging = false local currentValue = defaultValue or minValue local function updateSlider(value) local normalized = math.clamp((value - minValue) / (maxValue - minValue), 0, 1) sliderFill.Size = UDim2.new(normalized, 0, 1, 0) sliderThumb.Position = UDim2.new(normalized, -10, 0, -5) valueLabel.Text = string.format("%.2f", value) currentValue = value if options.onChange then options.onChange(value) end end sliderThumb.MouseButton1Down:Connect(function() isDragging = true end) game:GetService("UserInputService").InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then isDragging = false end end) game:GetService("RunService").Heartbeat:Connect(function() if isDragging then local mouse = game:GetService("Players").LocalPlayer:GetMouse() local relativeX = mouse.X - sliderTrack.AbsolutePosition.X local normalized = math.clamp(relativeX / sliderTrack.AbsoluteSize.X, 0, 1) local value = minValue + (maxValue - minValue) * normalized updateSlider(value) end end) -- Инициализация updateSlider(currentValue) table.insert(self.elements, { instance = sliderFrame, phase = options.phase }) return { frame = sliderFrame, getValue = function() return currentValue end, setValue = function(value) updateSlider(math.clamp(value, minValue, maxValue)) end } end -- Метод для очистки function GUILibrary:destroy() for _, connection in pairs(self.connections) do connection:Disconnect() end if self.screenGui then self.screenGui:Destroy() end setmetatable(self, nil) end return GUILibrary
Editor Settings
Theme
Key bindings
Full width
Lines