Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does picking up items share across everyone?

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)

1 answer

✓ Accepted answer

assuming that this is a LocalScript, you have to check to make sure that the part was touched was actually the localplayer's character

you can do that by just checking its parent

bluepart.Touched:Connect(function(hit)
	if hit.Parent == game.Players.LocalPlayer.Character then
		-- stuff
	end
end)

-- same thing for green part

This discussion is preserved as it was. New answers, comments, and votes are closed.