Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Inventory System --
- game.StarterGui:SetCoreGuiEnabled("Backpack",false) -- Disables the default backpack from being accessed
- local UserInput = game:GetService("UserInputService") -- Enables service to capture different types of input, USE THIS OVER KEYDOWN!
- local inventory = {}
- local plr = game.Players.LocalPlayer
- local character = plr.Character
- local back = plr.Backpack
- UserInput.InputBegan:connect(function(InputObject,Processed) -- Begins the function, the ",Procssed" means that it will not fire unless game is focused.
- if InputObject.KeyCode == Enum.KeyCode.Nine then -- Replace KeyCode.One with whatever KeyCode correlates to the button you want, https://developer.roblox.com/en-us/api-reference/enum/KeyCode
- if script.Parent.Enabled == true then
- print('Closed Inventory')
- script.Parent.Enabled = false
- elseif script.Parent.Enabled == false then
- print('Opened Inventory')
- script.Parent.Enabled = true
- end
- end
- end)
- slotnum = script.Parent.slotnum.Value
- character.ChildAdded:Connect(function(itm)
- if itm.className == "Tool" and slotnum < 11 then
- local slot = tostring("slot"..slotnum)
- local currentslot = script.Parent[slot]
- local itempicture = itm.picture.Value
- local itemname = itm.Name
- local itemnamevalue = currentslot.item
- -- inv
- -- sets item in inventory
- print("Slot Number "..slot)
- print("Item "..itemname)
- itemnamevalue.Value = itemname
- if inventory[itemname] == nil then
- currentslot.img.Image = itempicture
- inventory[itemname] = slot
- slotnum = slotnum + 1
- end
- elseif slotnum > 10 then
- -- detects max items
- script.Parent.Parent.text.TextLabel.Text = "You cannot carry any more items."
- wait(2)
- script.Parent.Parent.text.TextLabel.Text = " "
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement