Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. -- Inventory System --
  2. game.StarterGui:SetCoreGuiEnabled("Backpack",false) -- Disables the default backpack from being accessed
  3. local UserInput = game:GetService("UserInputService") -- Enables service to capture different types of input, USE THIS OVER KEYDOWN!
  4.  
  5.  
  6. local inventory = {}
  7.  
  8. local plr = game.Players.LocalPlayer
  9. local character = plr.Character
  10. local back = plr.Backpack
  11.  
  12. UserInput.InputBegan:connect(function(InputObject,Processed) -- Begins the function, the ",Procssed" means that it will not fire unless game is focused.
  13. 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
  14. if script.Parent.Enabled == true then
  15. print('Closed Inventory')
  16. script.Parent.Enabled = false
  17. elseif script.Parent.Enabled == false then
  18. print('Opened Inventory')
  19. script.Parent.Enabled = true
  20. end
  21. end
  22. end)
  23.  
  24. slotnum = script.Parent.slotnum.Value
  25.  
  26.  
  27. character.ChildAdded:Connect(function(itm)
  28. if itm.className == "Tool" and slotnum < 11 then
  29. local slot = tostring("slot"..slotnum)
  30. local currentslot = script.Parent[slot]
  31. local itempicture = itm.picture.Value
  32. local itemname = itm.Name
  33. local itemnamevalue = currentslot.item
  34. -- inv
  35.  
  36. -- sets item in inventory
  37.  
  38. print("Slot Number "..slot)
  39. print("Item "..itemname)
  40. itemnamevalue.Value = itemname
  41.  
  42. if inventory[itemname] == nil then
  43. currentslot.img.Image = itempicture
  44. inventory[itemname] = slot
  45. slotnum = slotnum + 1
  46. end
  47.  
  48.  
  49. elseif slotnum > 10 then
  50. -- detects max items
  51. script.Parent.Parent.text.TextLabel.Text = "You cannot carry any more items."
  52. wait(2)
  53. script.Parent.Parent.text.TextLabel.Text = " "
  54. end
  55. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement