How do I make a STRING determine a VALUE in a table?

How do I make a string inside a table determine a value?

I thought I could do it like this:
image

But I just got errors all across.
Script:

local conversionRate = {}

local function getConversionRates(player)
	
	local size = 0
	
	local items = {
		"Box",
		"Bag",
		"Can",
		"Furniture",
	}
	
	
	local trash = player.Character.Trash:GetDescendants()
	for _, descendant in pairs(trash) do
		if  descendant:IsA("Folder") then
			for _, item in pairs(items) do
				if item == descendant.Name then
					
				end
			end
		end
	end
end

return conversionRate

Put the string key in a square bracket just like that: ["string"].

The table that is in your provided script items is considered an array not a dictionary.
I suggest you read this documentation page.

Add square brackets between your strings.

Works, looks like:

["Box"] = size(1),

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.