Moving & Replacing Tables?

I’m currently working on a Party system for my game - However, for the life of me I cannot figure out how to swap the placements of two tables.
i.e. Party Slot1 > Storage Box1 Slot1 and vice versa.

I’ve attached a code I’ve been working on – However, even with that for some reason it doesn’t return to required table? However it does print it?
I don’t understand. :confused: Been struggling with this for close to 3 days now.


	local Core = { ... }
	local Server, Script = game, script
	
	local Bloxiimo = {
		Party = {
			[1] = {{'Flare'}},
			[2] = {{'Flambit'}},
		},
		
		Storage = {
			[1] = {
				[1] = {},
				[2] = {},
				[3] = {}
			},
			
			[2] = {
				[1] = {},
				[2] = {},
				[3] = {}
			}
		}
	}

	function Filter(t, req)
		for a, b in (t) do
			if type(b) == 'table' then
				if b == req then
					return b
				else
					Filter(b, req)
				end
			end
		end
	end

	function Core:Move(From, ...)
		
		print(Filter(Bloxiimo, From))
		
	end

	Core:Move(Bloxiimo.Party[1])
	
	return Core

Indexing the table you wanna move and then set the MovedTable to the Position of the initial table, here is an example

local SuperCoolTable = {
	{
		"I am super cool"
	},
	{
		"I lied"
	}
}

local InitialTable = SuperCoolTable[1]
local MovedTable = SuperCoolTable[2]
print(SuperCoolTable)
SuperCoolTable[1] = MovedTable
SuperCoolTable[2] = InitialTable
print(SuperCoolTable)

image

Brilliant! -
To add to this is there any way of editing a table when it’s referenced elsewhere?

By this I mean I insert each Frame from a GUI into a table that references each slot. So:

Frame[Textbutton] = PathToReferenceTable

However if I edit it from that reference, then the actual table is unchanged?

Depends.

If it it is one-sided communication on the server, yea
image

However if the changes are happening on the client, nothing really happens on the server
image

Server will change the table of lets say a modulescript, clients dont really, they will just change the table locally and if then taken from the server, the table is normal like it was.

Yeah my table is retrieved via :InvokeServer(); However when I adjust it from anywhere else in the same script I get no results.

However going forward with that, if I were to retrieve it then clone it and adjust from there would it change accordingly?

You mean like if I clone a table from another table, it will change when it has to (to match the “parent”)?

Yeah and then I can return the adjusted table back to the server to adjust?

Uhhh this has to do with some methamethods, specifically __newindex, which fires when a table of something does not equal to the table anymore (basically when something changed). Not sure how Metamethods work on that (i still have to learn them too). You can probably do something with that

Just want to say Thank you! - That throwing of ideas around earlier really helped ; I’ve successfully done it through cloning the Table, editing it and returning it!