How to automatically assign variable to variable from a table (module script)?

Hi,
For example I have 50 parts (tagged) and each part (after touch) change my body colors (assigned to this part)

  1. variable of part is in Script
  2. in module script I have keys (name of pack colors) and values (for example numbers of assets or name of colors)

Script:

local object = (...) -- object is a touched part
local object.Name = "A1"
local aChange = require(game.ServerStorage.AModuleScripts.AChangeMScript)
v1 = nil
v2 = nil
v3 = nil

-- here must be function: object must find his own key from module script (which has the same name of object) and be assigned to it. 
-- then if object has found its own key (the same name like object), object knows and take all variables from this key (for example 30 variables) and assign them into variables in script, like this:

v1 = aChange(v11) 
v2 = aChange(v22)
v3 = aChange(v33)
(...)

Module Script:

local aChange = {	
	["A1"] = {
		v11 = 1;
		v22 = 2;
		v33 = 3;
	};
	["B2"] = {
		v11 = 11;
		v22 = 22;
		v33 = 33;
	};		
}
return aChange

I am sorry if I am not explaining very vell… (english is my 3rd language :expressionless: )
any ideas? thanks advice for every reply!

I think you just use the object.Name to index the dictionary from the module script.

local v11,v22,v33 = aChange[object.Name]
local v1,v2,v3 = aChange(v11), aChange(v22), aChange(v33)
2 Likes