Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- player.Backpack.ChildAdded:Connect(function(child)
- wait(.2)
- local stacked = nil
- for i, v in player.Inventory:GetChildren()do -------------Check if the item is already in the inventory
- if v:IsA("Folder") and v.Name == child.Name then
- stacked = true
- elseif v:IsA("Folder") and v.Name ~= child.Name then
- stacked = false
- end
- end
- -------------------------------------------------------------------------
- if stacked == true and child.Stackable.Value == true then ---------------if the item is in the inventory then it will stack
- for i , v in player.Inventory:GetDescendants()do
- wait()
- if v:IsA("IntValue") and v.Name == child.Name then
- if v.Name == child.Name and v.Value < Max_stacked_items.Consumable then
- v.Value += 1
- elseif v.Name == child.Name and v.Value == Max_stacked_items.Consumable then
- counted = v.Parent
- print(counted)
- return
- end
- end
- end
- local table1 = {}
- for i2, stack in table1 do
- wait()
- print("ran1")
- if stack.StackId ~= counted.Parent.StackId then
- print("ran2")
- table.insert(table1, counted)
- local stack = Instance.new("Folder")
- stack.Name = child.Name
- stack.Parent = player.Inventory
- local stackid = Instance.new("IntValue")
- stackid.Name = "StackId"
- stackid.Value = Max_stacked_items.StackId + 1
- stackid.Parent = stack
- local new = Instance.new("IntValue")
- new.Name = child.Name
- new.Parent = stack
- new.Value = 1
- print("Ran")
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment