Using ReplicatedStorage to store player items?

Can you just give me a basic explanation of what you’re trying to accomplish and how it currently works because I believe I can make your system much more efficient and easy to work with :slight_smile:

Is the players inventory stored as a table? As in a module script contains every players inventory, or is the inventory a set of objects in a folder?

1 Like

Inventory is stored on server like so

Inventory = {
		Main = {
			[1] = {},
			[2] = {Type = 'Tool', Name = 'Wooden Axe', Durability = 50},
			[3] = {},
			[4] = {},
			[5] = {}
		},
		Stored = {
			[1] = {},
			[2] = {},
			[3] = {},
			[4] = {},
			[5] = {},
			[6] = {},
			[7] = {},
			[8] = {},
			[9] = {},
			[10] = {}		
		}
	}

Client gets a copy, like so

local PlayersInventory = InventoryCheck:InvokeServer() -- this would equal the table above

Then I setup their inventory UI like so

local function Setup()
	for i, v in pairs(PlayersInventory.Main) do
		if v.Type then
			local Slot = MainSlots:FindFirstChild(i)
			if Slot then
				local InventoryDefaultData = InventoryData[v.Type][v.Name]
				Slot.Holder.Item.Value = Items[v.Type][v.Name]
				Slot.Holder.Icon.Image = InventoryDefaultData.Image
				
				if v.Quantity then
					Slot.Holder.Quantity.Text = v.Quantity
				end
				
				if v.Durability then
					UpdateDurabilityBar(true, Slot.Holder, v.Durability, InventoryDefaultData)
				else
					UpdateDurabilityBar(false, Slot.Holder)
				end
			end
		end
	end
end

How each slot looks

Awesome, thanks. Here’s a basic flow of what should be happening

  1. Client receives data from server
  2. Client “decodes” data
  3. When client needs to equip or unequipped a tool, invoke server passing the name as an argument
  4. Server receives this, validates that the client owns the tool by looping through all items of inventory, comparing names.
  5. If the client owns the tool, clone the tool from ServerStorage into the players backpack.
  6. If the client does not own the tool, return or say some sort of message
  7. If a client needs to unequip a tool, just remove it from character, no need to validate anything.

That’s a basic system for equipping and un-equipping tools.

Ye that’s basically what I’ve got going at the moment :smiley:

1 Like

Client checks can be basic and effective

-- LocalScript under StarterCharacterScripts
script.Parent.ChildAdded:Connect(function(child)
    if child:IsA("Tool") then
        local valid = SomeRemote:InvokeServer(child)
        if not valid then child:Destroy()
    end
end)
1 Like

Nevermind. I still need a way of storing them on the client as object values ://// ran into problems where if you have multiples of the same item it doesn’t know which item to take durability etc. from. So it needs to have an actual object assigned to each slot, so it knows

I’m not sure but I think it would be better to store players inventory in Server Storage, as it is not able to be accessed locally, but then again I’m not sure as I’m fairly new to scripting.