Updating Nested Tables Using a String FullName and a Value

Hi everyone,

I’ve been trying to make a functioning inventory system where the server sends an updated inventory to the client, BUT also cut down on data. In order to do this, I’ve been trying to send only snippets of the inventory at once so it doesn’t hog up a bunch of bandwidth.

Anyway, let’s say the server were to send a string full name and a value like so:
local fullName = "Tbl.Value.AnotherValue", 500

And get the value in the table and update it like so:
local Tbl = {Value = {AnotherValue = 200}}

Currently, I’m using string.split() to separate each key into a table, and looping through with those keys to find the value. However, I have no idea how to update the value once I’ve actually gotten to it, as just setting the value with my current setup does nothing.

local function partialInventoryChanged(indexFullName, value)
	local iTbl = string.split(indexFullName, ".")
	local newInv = inventory
	local ct = newInv
	for i,v in ipairs(iTbl) do
		if i >= #iTbl then
			--Setting something here does nothing!!
			break
		elseif typeof(ct[v]) == "table" then
			ct = ct[v]
		end
	end
end

I’ve been kinda stuck on this issue for the past hour or so, and would really appreciate some help!