Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- --Inventory Handling
- local currentPlayerInventory = nil;
- local currentSection = "Weapons"
- local inventoryOpened = false
- local InventoryUI = script.Parent:WaitForChild("Inventory")
- local InventoryEvent = game.ReplicatedStorage:WaitForChild("Remotes").Inventory
- function refreshInventory(Section)
- if inventoryOpened == true and currentPlayerInventory ~= nil then
- if currentPlayerInventory[currentSection] ~= nil then
- for x, Slot in pairs(InventoryUI.Scene.Container:GetChildren()) do
- if Slot:IsA("UIGridLayout") == false then
- Slot:Destroy();
- end
- end
- if currentPlayerInventory["Equipped"..string.sub(Section,1,#Section-1)] ~= nil and currentPlayerInventory["Equipped"..string.sub(Section,1,#Section-1)] ~= "None" then
- local newSlot = InventoryUI:WaitForChild("Slot"):Clone()
- newSlot.ItemName.Text = currentPlayerInventory["Equipped"..string.sub(Section,1,#Section-1)].Name
- newSlot.Parent = InventoryUI.Scene.Container
- newSlot.Equip.MouseButton1Click:Connect(function()
- InventoryEvent:FireServer("Unequip",currentPlayerInventory["Equipped"..string.sub(Section,1,#Section-1)])
- end)
- end
- for x, invSlot in pairs(currentPlayerInventory[currentSection]) do
- local newSlot = InventoryUI:WaitForChild("Slot"):Clone()
- newSlot.ItemName.Text = invSlot.Name
- newSlot.Parent = InventoryUI.Scene.Container
- newSlot.Equip.MouseButton1Click:Connect(function()
- InventoryEvent:FireServer("Equip",invSlot)
- end)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement