Dictionary Value gets cut off when sent from server to client

I’m making an inventory system, which allows you to swap slots and move items onto your hotbar.

I’m having this weird issue that the value from the server-side is different from the client-side, the [30] slot seems to be stripped off.

image

Heres the basic code im using:

-- Client Side (Inventory)

local InvContents = Remotes.Inventory.getInventoryContents:InvokeServer()
print(InvContents)

-- Server Side (InventoryHandler)

ReplicatedStorage.Remotes.Inventory.getInventoryContents.OnServerInvoke = function(player)
	-- redraw
	local d = InventoryManager.GetAllItemsWithinInventory(player)
	print(d)
	return d
end

-- Server Side (InventoryManager (Module))

function IH.GetAllItemsWithinInventory(player)
	invExists(player)
	print(inventories[player.UserId])
	return inventories[player.UserId]
end


Thank you, Dwifte

I’d also like to add that the value [30] is exactly the same to value [7] and [8] (just a tag value is different)

Indices 9 to 29 are considered empty slots, something Bindables and Remotes dislike. If you need to keep the numbers, you have to use strings instead:

-- To check for the right number, you have to use numbers in strings
-- instead of number values themselves (e.g "2", not 2)
local T = {
	["1"] = {...},
	["2"] = {...},
	["5"] = {...},

Or with a bunch of tables which store the numbers instead:

local T = {
	{
		Slot = 1,
		...
	},
	{
		Slot = 4,
		...
	},
	...
}

Edit 2: and i may have spammed enter key too fast while in the original text that i posted my answer without finishing it.

1 Like

Oh! I never knew this! I’ll try it out and see if it works.

1 Like