| |
|
| |
|
| |
|
| | local Players = game:GetService("Players")
|
| | local UserInputService = game:GetService("UserInputService")
|
| | local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
| |
|
| | local player = Players.LocalPlayer
|
| | local ShopConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("ShopConfig"))
|
| | local EquipToolEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("EquipToolEvent")
|
| | local ShopEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("ShopEvent")
|
| |
|
| | local screenGui = Instance.new("ScreenGui")
|
| | screenGui.Name = "InventoryGUI"
|
| | screenGui.ResetOnSpawn = false
|
| | screenGui.Parent = player:WaitForChild("PlayerGui")
|
| |
|
| | local mainFrame = Instance.new("Frame")
|
| | mainFrame.Name = "InventoryFrame"
|
| | mainFrame.Size = UDim2.new(0, 400, 0, 350)
|
| | mainFrame.Position = UDim2.new(0.5, -200, 0.5, -175)
|
| | mainFrame.BackgroundColor3 = Color3.fromRGB(25, 28, 35)
|
| | mainFrame.BackgroundTransparency = 0.05
|
| | mainFrame.BorderSizePixel = 0
|
| | mainFrame.Visible = false
|
| | mainFrame.Parent = screenGui
|
| |
|
| | local corner = Instance.new("UICorner")
|
| | corner.CornerRadius = UDim.new(0, 12)
|
| | corner.Parent = mainFrame
|
| |
|
| | local stroke = Instance.new("UIStroke")
|
| | stroke.Color = Color3.fromRGB(100, 130, 200)
|
| | stroke.Thickness = 2
|
| | stroke.Parent = mainFrame
|
| |
|
| |
|
| | local titleBar = Instance.new("Frame")
|
| | titleBar.Size = UDim2.new(1, 0, 0, 40)
|
| | titleBar.BackgroundColor3 = Color3.fromRGB(50, 70, 120)
|
| | titleBar.BorderSizePixel = 0
|
| | titleBar.Parent = mainFrame
|
| |
|
| | local titleCorner = Instance.new("UICorner")
|
| | titleCorner.CornerRadius = UDim.new(0, 12)
|
| | titleCorner.Parent = titleBar
|
| |
|
| | local titleLabel = Instance.new("TextLabel")
|
| | titleLabel.Size = UDim2.new(1, -50, 1, 0)
|
| | titleLabel.Position = UDim2.new(0, 15, 0, 0)
|
| | titleLabel.BackgroundTransparency = 1
|
| | titleLabel.Text = "Inventory"
|
| | titleLabel.TextColor3 = Color3.new(1, 1, 1)
|
| | titleLabel.TextScaled = true
|
| | titleLabel.Font = Enum.Font.GothamBold
|
| | titleLabel.TextXAlignment = Enum.TextXAlignment.Left
|
| | titleLabel.Parent = titleBar
|
| |
|
| | local closeBtn = Instance.new("TextButton")
|
| | closeBtn.Size = UDim2.new(0, 30, 0, 30)
|
| | closeBtn.Position = UDim2.new(1, -35, 0, 5)
|
| | closeBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
|
| | closeBtn.Text = "X"
|
| | closeBtn.TextColor3 = Color3.new(1, 1, 1)
|
| | closeBtn.TextScaled = true
|
| | closeBtn.Font = Enum.Font.GothamBold
|
| | closeBtn.Parent = titleBar
|
| |
|
| | local closeCorner = Instance.new("UICorner")
|
| | closeCorner.CornerRadius = UDim.new(0, 6)
|
| | closeCorner.Parent = closeBtn
|
| |
|
| | closeBtn.MouseButton1Click:Connect(function()
|
| | mainFrame.Visible = false
|
| | end)
|
| |
|
| |
|
| | local scrollFrame = Instance.new("ScrollingFrame")
|
| | scrollFrame.Size = UDim2.new(1, -20, 1, -55)
|
| | scrollFrame.Position = UDim2.new(0, 10, 0, 45)
|
| | scrollFrame.BackgroundColor3 = Color3.fromRGB(15, 18, 22)
|
| | scrollFrame.BorderSizePixel = 0
|
| | scrollFrame.ScrollBarThickness = 6
|
| | scrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
|
| | scrollFrame.Parent = mainFrame
|
| |
|
| | local scrollCorner = Instance.new("UICorner")
|
| | scrollCorner.CornerRadius = UDim.new(0, 8)
|
| | scrollCorner.Parent = scrollFrame
|
| |
|
| | local gridLayout = Instance.new("UIGridLayout")
|
| | gridLayout.CellSize = UDim2.new(0, 110, 0, 70)
|
| | gridLayout.CellPadding = UDim2.new(0, 8, 0, 8)
|
| | gridLayout.SortOrder = Enum.SortOrder.LayoutOrder
|
| | gridLayout.Parent = scrollFrame
|
| |
|
| | local padding = Instance.new("UIPadding")
|
| | padding.PaddingTop = UDim.new(0, 5)
|
| | padding.PaddingLeft = UDim.new(0, 5)
|
| | padding.Parent = scrollFrame
|
| |
|
| |
|
| | local currentInventory = nil
|
| |
|
| | local function refreshInventory(inventory)
|
| | currentInventory = inventory
|
| |
|
| | for _, child in pairs(scrollFrame:GetChildren()) do
|
| | if child:IsA("Frame") then child:Destroy() end
|
| | end
|
| |
|
| | if not inventory then return end
|
| |
|
| | local idx = 0
|
| | for category, items in pairs(inventory) do
|
| | for _, itemId in ipairs(items) do
|
| | idx = idx + 1
|
| | local itemData = ShopConfig.Items[itemId]
|
| | local itemName = itemData and itemData.Name or itemId
|
| |
|
| | local card = Instance.new("Frame")
|
| | card.Name = itemId .. "_" .. idx
|
| | card.LayoutOrder = idx
|
| | card.BackgroundColor3 = Color3.fromRGB(40, 45, 55)
|
| | card.BorderSizePixel = 0
|
| | card.Parent = scrollFrame
|
| |
|
| | local cardCorner = Instance.new("UICorner")
|
| | cardCorner.CornerRadius = UDim.new(0, 6)
|
| | cardCorner.Parent = card
|
| |
|
| | local nameLabel = Instance.new("TextLabel")
|
| | nameLabel.Size = UDim2.new(1, -6, 0, 22)
|
| | nameLabel.Position = UDim2.new(0, 3, 0, 3)
|
| | nameLabel.BackgroundTransparency = 1
|
| | nameLabel.Text = itemName
|
| | nameLabel.TextColor3 = Color3.new(1, 1, 1)
|
| | nameLabel.TextScaled = true
|
| | nameLabel.Font = Enum.Font.GothamBold
|
| | nameLabel.Parent = card
|
| |
|
| | local typeLabel = Instance.new("TextLabel")
|
| | typeLabel.Size = UDim2.new(1, -6, 0, 15)
|
| | typeLabel.Position = UDim2.new(0, 3, 0, 25)
|
| | typeLabel.BackgroundTransparency = 1
|
| | typeLabel.Text = category
|
| | typeLabel.TextColor3 = Color3.fromRGB(150, 150, 180)
|
| | typeLabel.TextScaled = true
|
| | typeLabel.Font = Enum.Font.Gotham
|
| | typeLabel.Parent = card
|
| |
|
| |
|
| | if category == "Tools" then
|
| | local equipBtn = Instance.new("TextButton")
|
| | equipBtn.Size = UDim2.new(0.8, 0, 0, 20)
|
| | equipBtn.Position = UDim2.new(0.1, 0, 1, -23)
|
| | equipBtn.BackgroundColor3 = Color3.fromRGB(60, 120, 200)
|
| | equipBtn.Text = "Equip"
|
| | equipBtn.TextColor3 = Color3.new(1, 1, 1)
|
| | equipBtn.TextScaled = true
|
| | equipBtn.Font = Enum.Font.GothamBold
|
| | equipBtn.Parent = card
|
| |
|
| | local eqCorner = Instance.new("UICorner")
|
| | eqCorner.CornerRadius = UDim.new(0, 4)
|
| | eqCorner.Parent = equipBtn
|
| |
|
| | equipBtn.MouseButton1Click:Connect(function()
|
| | EquipToolEvent:FireServer(itemId)
|
| | end)
|
| | end
|
| | end
|
| | end
|
| |
|
| | task.wait()
|
| | scrollFrame.CanvasSize = UDim2.new(0, 0, 0, gridLayout.AbsoluteContentSize.Y + 15)
|
| | end
|
| |
|
| |
|
| | ShopEvent.OnClientEvent:Connect(function(action, data)
|
| | if action == "InventoryUpdate" then
|
| | refreshInventory(data)
|
| | end
|
| | end)
|
| |
|
| |
|
| | UserInputService.InputBegan:Connect(function(input, gameProcessed)
|
| | if gameProcessed then return end
|
| | if input.KeyCode == Enum.KeyCode.I then
|
| | mainFrame.Visible = not mainFrame.Visible
|
| | end
|
| | end)
|
| |
|