Advertisement
Podiszka

Untitled

Dec 9th, 2022
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | Software | 0 0
  1. local Events = game.ReplicatedStorage:WaitForChild("Events")
  2. local Settings = script.Parent:WaitForChild("Settings")
  3. local InvSpace = Settings:WaitForChild("InvSpace")
  4. local MaxInvSpace = Settings:WaitForChild("MaxInvSpace")
  5. local MaxItemsPerSlot = Settings:WaitForChild("MaxItemsPerSlot")
  6.  
  7. local Player = game.Players.LocalPlayer
  8.  
  9. local Temp = script.Temp
  10. local Frame = script.Parent
  11. local PlayerInv = Frame:WaitForChild("PlayerInventory")
  12.  
  13. local function UpdateGui()
  14.     for i, v in pairs(PlayerInv:GetChildren()) do
  15.         if v:IsA("ImageButton") then
  16.             v:Destroy()
  17.         end
  18.     end
  19.    
  20.     for i, v in pairs(Player.Inventory:GetChildren()) do
  21.         local NewItem = Temp:Clone()
  22.        
  23.         NewItem.Parent = PlayerInv
  24.         NewItem.Name = v.Name
  25.         NewItem.ItemName.Text = v.Name
  26.         NewItem.ItemValue.Text = v.Value
  27.         NewItem.Image = "rbxassetid://".. v.ImageID.Value
  28.        
  29.                
  30.         NewItem.MouseButton2Click:Connect(function()
  31.             Events.ThrowBlock:FireServer(v.Name)
  32.         end)
  33.     end
  34.    
  35.     local Inv = Player.Inventory:GetChildren()
  36.     InvSpace.Value = #Inv
  37.    
  38.     Frame.Title2.Text = InvSpace.Value.. "/".. MaxInvSpace.Value
  39. end
  40.  
  41. Events.UpdateInventory.OnClientEvent:Connect(function()
  42.     UpdateGui()
  43. end)
  44.  
  45. Events.DeleteItemFromInv.OnClientEvent:Connect(function(Item)
  46.     if PlayerInv:FindFirstChild(Item) then
  47.         PlayerInv:FindFirstChild(Item):Destroy()
  48.     end
  49. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement