Создам GUI для инвентаря в черно-сером стиле. Вот скрипт для создания интерфейса:
-- InventoryGUI.lua
local ScreenGui = Instance.new("ScreenGui")
local MainFrame = Instance.new("Frame")
local Title = Instance.new("TextLabel")
local ItemsGrid = Instance.new("ScrollingFrame")
local UIGridLayout = Instance.new("UIGridLayout")
local CloseButton = Instance.new("TextButton")
local ToggleButton = Instance.new("TextButton")
-- Настройка основного GUI
ScreenGui.Name = "InventoryGui"
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
ScreenGui.ResetOnSpawn = false
-- Основная рамка инвентаря
MainFrame.Name = "MainFrame"
MainFrame.Size = UDim2.new(0, 400, 0, 500)
MainFrame.Position = UDim2.new(0.5, -200, 0.5, -250)
MainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25) -- Тёмный фон
MainFrame.BorderSizePixel = 0
MainFrame.Parent = ScreenGui
MainFrame.Visible = false
-- Создаем закругленные углы
local UICorner = Instance.new("UICorner")
UICorner.CornerRadius = UDim.new(0, 10)
UICorner.Parent = MainFrame
-- Заголовок
Title.Name = "Title"
Title.Size = UDim2.new(1, 0, 0, 40)
Title.Position = UDim2.new(0, 0, 0, 0)
Title.BackgroundColor3 = Color3.fromRGB(35, 35, 35) -- Чуть светлее фона
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.Text = "Инвентарь"
Title.TextSize = 24
Title.Font = Enum.Font.GothamBold
Title.Parent = MainFrame
local TitleCorner = Instance.new("UICorner")
TitleCorner.CornerRadius = UDim.new(0, 10)
TitleCorner.Parent = Title
-- Сетка предметов
ItemsGrid.Name = "ItemsGrid"
ItemsGrid.Size = UDim2.new(0.95, 0, 0.85, 0)
ItemsGrid.Position = UDim2.new(0.025, 0, 0.12, 0)
ItemsGrid.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
ItemsGrid.BorderSizePixel = 0
ItemsGrid.ScrollBarThickness = 6
ItemsGrid.Parent = MainFrame
-- Настройка сетки
UIGridLayout.Parent = ItemsGrid
UIGridLayout.CellSize = UDim2.new(0, 80, 0, 80)
UIGridLayout.CellPadding = UDim2.new(0, 10, 0, 10)
UIGridLayout.SortOrder = Enum.SortOrder.LayoutOrder
-- Кнопка закрытия
CloseButton.Name = "CloseButton"
CloseButton.Size = UDim2.new(0, 30, 0, 30)
CloseButton.Position = UDim2.new(1, -35, 0, 5)
CloseButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
CloseButton.Text = "X"
CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
CloseButton.TextSize = 20
CloseButton.Font = Enum.Font.GothamBold
CloseButton.Parent = MainFrame
local CloseCorner = Instance.new("UICorner")
CloseCorner.CornerRadius = UDim.new(0, 5)
CloseCorner.Parent = CloseButton
-- Кнопка переключения инвентаря
ToggleButton.Name = "ToggleButton"
ToggleButton.Size = UDim2.new(0, 120, 0, 40)
ToggleButton.Position = UDim2.new(0, 10, 0.95, -45)
ToggleButton.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
ToggleButton.Text = "Инвентарь"
ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
ToggleButton.TextSize = 18
ToggleButton.Font = Enum.Font.GothamSemibold
ToggleButton.Parent = ScreenGui
local ToggleCorner = Instance.new("UICorner")
ToggleCorner.CornerRadius = UDim.new(0, 8)
ToggleCorner.Parent = ToggleButton
-- Функция создания ячейки инвентаря
local function CreateItemSlot()
local ItemSlot = Instance.new("Frame")
ItemSlot.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
ItemSlot.BorderSizePixel = 0
local SlotCorner = Instance.new("UICorner")
SlotCorner.CornerRadius = UDim.new(0, 8)
SlotCorner.Parent = ItemSlot
local ItemImage = Instance.new("ImageLabel")
ItemImage.Size = UDim2.new(0.8, 0, 0.8, 0)
ItemImage.Position = UDim2.new(0.1, 0, 0.1, 0)
ItemImage.BackgroundTransparency = 1
ItemImage.Parent = ItemSlot
local ItemCount = Instance.new("TextLabel")
ItemCount.Size = UDim2.new(0.4, 0, 0.2, 0)
ItemCount.Position = UDim2.new(0.6, 0, 0.8, 0)
ItemCount.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
ItemCount.TextColor3 = Color3.fromRGB(255, 255, 255)
ItemCount.Text = "0"
ItemCount.TextSize = 14
ItemCount.Font = Enum.Font.GothamBold
ItemCount.Parent = ItemSlot
return ItemSlot
end
-- Создаем начальные слоты
for i = 1, 24 do
local slot = CreateItemSlot()
slot.Parent = ItemsGrid
end
-- Обработчики событий
CloseButton.MouseButton1Click:Connect(function()
MainFrame.Visible = false
end)
ToggleButton.MouseButton1Click:Connect(function()
MainFrame.Visible = not MainFrame.Visible
end)
-- Добавляем эффекты наведения
local function createHoverEffect(button)
button.MouseEnter:Connect(function()
game:GetService("TweenService"):Create(button,
TweenInfo.new(0.3),
{BackgroundColor3 = Color3.fromRGB(60, 60, 60)}
):Play()
end)
button.MouseLeave:Connect(function()
game:GetService("TweenService"):Create(button,
TweenInfo.new(0.3),
{BackgroundColor3 = Color3.fromRGB(45, 45, 45)}
):Play()
end)
end
createHoverEffect(ToggleButton)