I’m developing an inventory system and I’m trying to access image ID’s through a ModuleScript dictionary. In the code I have, items and their values are passed to the client via parameters in a function: local function FillSlot(Num1,Item1,Num2,Item2,Num3,Item3,Num4,Item4)
. The Item1,Item2,etc is the names of the objects. I take the item names and get rid of the whitespace if they aren’t nil.
if Item1 then
local Item1Image = string.gsub(Item1, "%s+","")
end
if Item2 then
local Item2Image = string.gsub(Item2, "%s+","")
end
if Item3 then
local Item3Image = string.gsub(Item3, "%s+","")
end
if Item4 then
local Item4Image = string.gsub(Item4, "%s+","")
end
Those unwhitespaced names are the same as what they’re called in the dictionary. I want to be able to use those ItemImage variables to access parts of that dictionary. Like a functioning version of this line: v.ItemImage.Image = ItemImages.Item1Image
. how would it be achieved? (ItemImages is the module script being referenced.)