95Roadkill

Roblox, Selecting Items in inventory.

Dec 12th, 2015
5,705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. local ItemInfo = require(game.Workspace.Items)
  2. Player = script.Parent.Parent.Parent
  3. PlyGame = game.Players:FindFirstChild(Player.Name)
  4. Mouse = Player:GetMouse()
  5. ItemClickScan = 0
  6. MaxScan = 28
  7. print("Welcome to RoScape " ..Player.Name .. "!")
  8. print("If you find any bugs please click on 'Sever Console' and send me the error in a message (redface95)")
  9. local debounce = false
  10. local ItemFrameAmount = 0
  11.  
  12. while true do
  13.     PlyGame:WaitForChild("Inventory")
  14.     PlyGame.Inventory:WaitForChild("Item28")
  15.     ItemClickScan = ItemClickScan + 1
  16.     for i,v in pairs(script.Parent.Inventory:GetChildren()) do
  17.         if v:FindFirstChild("ItemButton") then
  18.             local SlotValue = v.Slot.Value
  19.             local ItemSlotValue = PlyGame.Inventory["Item"..SlotValue]
  20.             if ItemSlotValue.Value >= 1 then
  21.                 v.ItemButton.MouseButton2Down:connect(function()
  22.                     if debounce == true then return end
  23.                     debounce = true
  24.                     if script.Parent:FindFirstChild("ItemClick") then
  25.                         script.Parent.ItemClick:Remove()
  26.                     end
  27.                     local ItemId = ItemSlotValue.Id.Value
  28.                     print(v.Name)
  29.                     print(ItemId)
  30.                     print("RightClicked")
  31.                     local Frame = Instance.new("Frame",script.Parent)
  32.                         Frame.Name = "ItemClick"
  33.                         Frame.Size = UDim2.new(0,100,0,25)
  34.                     if ItemInfo[ItemId].CanBeEquiped == true then
  35.                         print("Can Equip")
  36.                         local Equip = Instance.new("TextButton",script.Parent.ItemClick)
  37.                             Equip.Name = "Wield"
  38.                             Equip.Text = "Wield"
  39.                             Equip.Size = UDim2.new(0,100,0,25)
  40.                             Equip.Position = UDim2.new(0,0,0,0)
  41.                             ItemFrameAmount = ItemFrameAmount + 1
  42.                     end
  43.                     local Use = Instance.new("TextButton",script.Parent.ItemClick)
  44.                         Use.Name = "Use"
  45.                         Use.Text = "Use"
  46.                         Use.Size = UDim2.new(0,100,0,25)
  47.                         Use.Position = UDim2.new(0,0,0,25*ItemFrameAmount)
  48.                         ItemFrameAmount = ItemFrameAmount + 1
  49.                     local Examine = Instance.new("TextButton",script.Parent.ItemClick)
  50.                         Examine.Name = "Examine"
  51.                         Examine.Text = "Examine"
  52.                         Examine.Size = UDim2.new(0,100,0,25)
  53.                         Examine.Position = UDim2.new(0,0,0,25*ItemFrameAmount)
  54.                         ItemFrameAmount = ItemFrameAmount + 1
  55.                     local Drop = Instance.new("TextButton",script.Parent.ItemClick)
  56.                         Drop.Name = "Drop"
  57.                         Drop.Text = "Drop"
  58.                         Drop.Size = UDim2.new(0,100,0,25)
  59.                         Drop.Position = UDim2.new(0,0,0,25*ItemFrameAmount)
  60.                         script.Parent.ItemClick.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
  61.                     Frame.Size = UDim2.new(0,100,0,25*ItemFrameAmount)
  62.                     wait(0.5)
  63.                     ItemFrameAmount = 0
  64.                     debounce = false
  65.                 end)
  66.             end
  67.             v.ItemButton.MouseButton1Down:connect(function()
  68.                 if debounce == true then return end
  69.                 debounce = true
  70.                 print("LeftClicked")
  71.                 wait(0.5)
  72.             debounce = false
  73.         end)
  74.         end
  75.         if ItemClickScan >= MaxScan then
  76.             ItemClickScan = 0
  77.         end
  78.     end
  79. wait(0.1)
  80. end
Advertisement
Add Comment
Please, Sign In to add comment