Advertisement
Aquarius_Raverus

oof

Apr 30th, 2020
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | None | 0 0
  1. game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
  2.  
  3. local Storage = game:GetService("ReplicatedStorage")
  4. local Modules = Storage:WaitForChild("Modules")
  5. local UIS = game:GetService("UserInputService")
  6.  
  7. local Inventory = require(Modules:WaitForChild('Inventory'))
  8. local Max_Backpack_Slots = Inventory['Max_Backpack_Slots']
  9.  
  10. local Events = Storage:WaitForChild("Events")
  11. local InventoryFunction = Events:WaitForChild('InventoryFunction')
  12. local GetDesc = Events:WaitForChild('GetDescription')
  13.  
  14. local Template = script:WaitForChild("Template")
  15. local ButtonTemplate = script:WaitForChild("TextButton")
  16.  
  17. local BackpackFrame = script.Parent:WaitForChild("BackpackFrame")
  18.  
  19. local Default_Items = Storage:WaitForChild("DefaultItems")
  20.  
  21. local ItemEquipped = ""
  22. local CurrentNumber = 0
  23.  
  24. local Item_Slots = {   
  25.  
  26. }
  27.  
  28. local NumToWords = {
  29.  
  30.     [3] = 'Three',
  31.     [4] = 'Four',
  32.     [5] = 'Five',
  33.  
  34.  
  35. }
  36.  
  37. function update(action, itemChosen)
  38.     if action == 'Starter_Items' then
  39.    
  40.         local Children = Default_Items:GetChildren()
  41.            
  42.         for i = 1, Max_Backpack_Slots do
  43.             local Clone = Template:Clone()
  44.             Clone.Parent = BackpackFrame
  45.            
  46.             Clone.Name = i
  47.            
  48.         end
  49.        
  50.         for i = 1, #Children do
  51.             local Slot = Instance.new("NumberValue", BackpackFrame:FindFirstChild(i))
  52.            
  53.             Slot.Name = Children[i].Name
  54.             Slot.Value = Children[i].Value
  55.            
  56.             local Button = ButtonTemplate:Clone()
  57.             Button.Parent = BackpackFrame:FindFirstChild(i)
  58.            
  59.             Button.Text = Children[i].Name
  60.            
  61.        
  62.             table.insert(Item_Slots, i, {Children[i].Name, Children[i].Value, Children[i].Number.Value})
  63.             CurrentNumber = CurrentNumber + 1
  64.         end
  65.     end
  66.    
  67.     if action == 'NewItem' then
  68.         for i,v in pairs(BackpackFrame:GetChildren()) do
  69.             if v:FindFirstChild(itemChosen) then
  70.                 warn"Insert more numbers into object."
  71.                
  72.                 v[itemChosen].Value = v[itemChosen].Value + 1
  73.                
  74.                 break
  75.             elseif #v:GetChildren() > 0 then
  76.                 print("This already has children.")
  77.                
  78.             else
  79.        
  80.                 print('Inserting new object into this instance.')
  81.                 print(v.Name)
  82.                
  83.                 local Slot = Instance.new("NumberValue", v)
  84.                 Slot.Name = itemChosen
  85.                 Slot.Value = 1
  86.                
  87.                 local Clone = ButtonTemplate:Clone()
  88.                 Clone.Parent = v
  89.                 Clone.Text = itemChosen
  90.                
  91.                 CurrentNumber = CurrentNumber + 1
  92.                
  93.                 table.insert(Item_Slots, #Item_Slots, {v[itemChosen].Name, v[itemChosen].Value, NumToWords[CurrentNumber]})
  94.                
  95.                 break
  96.             end
  97.         end
  98.     end
  99. end
  100.  
  101.  
  102. -- color
  103.  
  104. --[[
  105. 168, 122, 84
  106. ]]--
  107.  
  108. wait(2)
  109.  
  110. update('Starter_Items')
  111.  
  112. InventoryFunction.OnClientInvoke = function(itemChosen , action)
  113.     if action == 'NewItem' then
  114.         update(action, itemChosen)
  115.     end
  116. end
  117.  
  118.  
  119. UIS.InputBegan:Connect(function(input, gpe)
  120.     if gpe then return end
  121.    
  122.     for _,v in pairs(Item_Slots) do
  123.         if input.KeyCode == Enum.KeyCode[v[3]] then
  124.             if ItemEquipped == "" then
  125.                 print(v[1])
  126.                
  127.                 ItemEquipped = tostring(v[1])
  128.                 InventoryFunction:InvokeServer(tostring(v[1]), "", GetDesc:InvokeServer('GetType', tostring(v[1])), 'EquipDefaultItem')
  129.                
  130.         for _,v in pairs(BackpackFrame:GetChildren()) do
  131.             if v:FindFirstChild(ItemEquipped) then
  132.                     v.ImageColor3 = Color3.fromRGB(168, 122, 84)
  133.                     end
  134.                 end
  135.             elseif ItemEquipped == v[1] then
  136.                 for _,v in pairs(BackpackFrame:GetChildren()) do
  137.                     if v:FindFirstChild(ItemEquipped) then
  138.                         v.ImageColor3 = Color3.fromRGB(223, 162, 112)
  139.                     end
  140.                 end
  141.            
  142.                 ItemEquipped = ""
  143.                
  144.                 InventoryFunction:InvokeServer(tostring(v[1]), "", GetDesc:InvokeServer('GetType', tostring(v[1])), 'UnEquip')
  145.    
  146.             else
  147.                 print"You must unequip your equipped item first."
  148.             end
  149.         end
  150.     end
  151. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement