Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
- local Storage = game:GetService("ReplicatedStorage")
- local Modules = Storage:WaitForChild("Modules")
- local UIS = game:GetService("UserInputService")
- local Inventory = require(Modules:WaitForChild('Inventory'))
- local Max_Backpack_Slots = Inventory['Max_Backpack_Slots']
- local Events = Storage:WaitForChild("Events")
- local InventoryFunction = Events:WaitForChild('InventoryFunction')
- local GetDesc = Events:WaitForChild('GetDescription')
- local Template = script:WaitForChild("Template")
- local ButtonTemplate = script:WaitForChild("TextButton")
- local BackpackFrame = script.Parent:WaitForChild("BackpackFrame")
- local Default_Items = Storage:WaitForChild("DefaultItems")
- local ItemEquipped = ""
- local CurrentNumber = 0
- local Item_Slots = {
- }
- local NumToWords = {
- [3] = 'Three',
- [4] = 'Four',
- [5] = 'Five',
- }
- function update(action, itemChosen)
- if action == 'Starter_Items' then
- local Children = Default_Items:GetChildren()
- for i = 1, Max_Backpack_Slots do
- local Clone = Template:Clone()
- Clone.Parent = BackpackFrame
- Clone.Name = i
- end
- for i = 1, #Children do
- local Slot = Instance.new("NumberValue", BackpackFrame:FindFirstChild(i))
- Slot.Name = Children[i].Name
- Slot.Value = Children[i].Value
- local Button = ButtonTemplate:Clone()
- Button.Parent = BackpackFrame:FindFirstChild(i)
- Button.Text = Children[i].Name
- table.insert(Item_Slots, i, {Children[i].Name, Children[i].Value, Children[i].Number.Value})
- CurrentNumber = CurrentNumber + 1
- end
- end
- if action == 'NewItem' then
- for i,v in pairs(BackpackFrame:GetChildren()) do
- if v:FindFirstChild(itemChosen) then
- warn"Insert more numbers into object."
- v[itemChosen].Value = v[itemChosen].Value + 1
- break
- elseif #v:GetChildren() > 0 then
- print("This already has children.")
- else
- print('Inserting new object into this instance.')
- print(v.Name)
- local Slot = Instance.new("NumberValue", v)
- Slot.Name = itemChosen
- Slot.Value = 1
- local Clone = ButtonTemplate:Clone()
- Clone.Parent = v
- Clone.Text = itemChosen
- CurrentNumber = CurrentNumber + 1
- table.insert(Item_Slots, #Item_Slots, {v[itemChosen].Name, v[itemChosen].Value, NumToWords[CurrentNumber]})
- break
- end
- end
- end
- end
- -- color
- --[[
- 168, 122, 84
- ]]--
- wait(2)
- update('Starter_Items')
- InventoryFunction.OnClientInvoke = function(itemChosen , action)
- if action == 'NewItem' then
- update(action, itemChosen)
- end
- end
- UIS.InputBegan:Connect(function(input, gpe)
- if gpe then return end
- for _,v in pairs(Item_Slots) do
- if input.KeyCode == Enum.KeyCode[v[3]] then
- if ItemEquipped == "" then
- print(v[1])
- ItemEquipped = tostring(v[1])
- InventoryFunction:InvokeServer(tostring(v[1]), "", GetDesc:InvokeServer('GetType', tostring(v[1])), 'EquipDefaultItem')
- for _,v in pairs(BackpackFrame:GetChildren()) do
- if v:FindFirstChild(ItemEquipped) then
- v.ImageColor3 = Color3.fromRGB(168, 122, 84)
- end
- end
- elseif ItemEquipped == v[1] then
- for _,v in pairs(BackpackFrame:GetChildren()) do
- if v:FindFirstChild(ItemEquipped) then
- v.ImageColor3 = Color3.fromRGB(223, 162, 112)
- end
- end
- ItemEquipped = ""
- InventoryFunction:InvokeServer(tostring(v[1]), "", GetDesc:InvokeServer('GetType', tostring(v[1])), 'UnEquip')
- else
- print"You must unequip your equipped item first."
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement