EliteGod532111

Untitled

Jul 12th, 2025
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. player.Backpack.ChildAdded:Connect(function(child)
  2.         wait(.2)
  3.                 local stacked = nil
  4.                
  5.                
  6.  
  7.                 for i, v in player.Inventory:GetChildren()do -------------Check if the item is already in the inventory
  8.                     if v:IsA("Folder") and v.Name == child.Name then
  9.                         stacked = true
  10.                     elseif v:IsA("Folder") and v.Name ~= child.Name then
  11.                         stacked = false
  12.                     end
  13.                 end
  14.                 -------------------------------------------------------------------------
  15.  
  16.  
  17.  
  18.  
  19.  
  20.                 if stacked == true and child.Stackable.Value == true then ---------------if the item is in the inventory then it will stack
  21.            
  22.                 for i , v in player.Inventory:GetDescendants()do
  23.                     wait()
  24.                
  25.                     if v:IsA("IntValue") and v.Name == child.Name then
  26.                        
  27.                         if v.Name == child.Name and v.Value < Max_stacked_items.Consumable then
  28.                            
  29.                             v.Value += 1
  30.                         elseif v.Name == child.Name and v.Value == Max_stacked_items.Consumable then
  31.                             counted = v.Parent
  32.                             print(counted)
  33.                             return
  34.                                
  35.                         end
  36.                     end
  37.                 end
  38.                
  39.                        
  40.                        
  41.                             local table1 = {}
  42.  
  43.                             for i2, stack in table1 do
  44.                                 wait()
  45.                                 print("ran1")
  46.  
  47.                                 if stack.StackId ~= counted.Parent.StackId then
  48.                                     print("ran2")
  49.                                     table.insert(table1, counted)
  50.  
  51.  
  52.                                     local stack = Instance.new("Folder")
  53.                                     stack.Name = child.Name
  54.                                     stack.Parent = player.Inventory
  55.  
  56.                                     local stackid = Instance.new("IntValue")
  57.                                     stackid.Name = "StackId"
  58.                                     stackid.Value = Max_stacked_items.StackId + 1
  59.                                     stackid.Parent = stack
  60.  
  61.                                     local new = Instance.new("IntValue")
  62.                                     new.Name = child.Name
  63.                                     new.Parent = stack
  64.                                     new.Value = 1
  65.                                     print("Ran")
  66.                                     return
  67.                                 end
  68.                             end
Advertisement
Add Comment
Please, Sign In to add comment