I am trying to make my own inventory. When I step on a part to get materials, the material is getting shared across everyone. I am trying to make it where you get your own materials without it getting shared across.
local inventory = script.Parent.Inventory
local inventoryslots = inventory.InventoryFrame:GetChildren()
local maxspaceperslot = 20
local bluepart = workspace.Blue
local greenpart = workspace.Green
local trashA = inventory.InventoryFrame.SlotA.Trash
local dropA = inventory.InventoryFrame.SlotA.Drop
local trashB = inventory.InventoryFrame.SlotB.Trash
local dropB = inventory.InventoryFrame.SlotB.Drop
local visible = false
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
--BluePart
bluepart.Touched:Connect(function()
for i,v in pairs(inventoryslots)do
if v.Item.Value == "" then
v.Item.Value = "Wood"
v.Amount.Value = 1
v.TextLabel.Text = v.Amount.Value
v.ImageLabel.Image = "rbxassetid://856547512"
break
elseif v.Item.Value =="Wood" then
v.Amount.Value = v.Amount.Value + 1
v.TextLabel.Text = v.Amount.Value
if v.Amount.Value >= maxspaceperslot then
print("Gone over the limit")
v.Amount.Value = 20
end
break
end
end
end)
-- Green Part
greenpart.Touched:Connect(function()
for i,v in pairs(inventoryslots) do
if v.Item.Value == "" then
v.Item.Value = "Stone"
v.Amount.Value = 1
v.TextLabel.Text = v.Amount.Value
v.ImageLabel.Image = "rbxassetid://141711415"
break
elseif v.Item.Value == "Stone" then
v.Amount.Value = v.Amount.Value + 1
v.TextLabel.Text = v.Amount.Value
if v.Amount.Value >= maxspaceperslot then
print("Stone Limit Reached")
v.Amount.Value = 20
end
break
end
end
end)
