How can I find something in a table with a string?

I’m making an item shop, and I have a content frame that appears with an item’s information when you select it. I am storing each item’s stats in a module. When I press a square to select an item, I’m trying to index this table with the square’s name, which is the same as the item. The problem is, a name is a string, and the things in the table aren’t named a string, and I can’t do that.
this is what the table looks like:

local Items = {
	
	Thing = {
		
		Cost = 100,
		Image = "http://www.roblox.com/asset/?id=14384692368"
		
	},
	
	OtherThing = {
		
		Cost = 200,
		Image = "http://www.roblox.com/asset/?id=14619776654"
		
	}
	
}

return Items

and this is me trying to index it for something:

local ItemsTable = require(game.ReplicatedStorage.Items.Items)
ContentFrame.Cost.Text = "¥ "tostring(table.find(ItemsTable, Square.Name).Cost)

if anyone knows how to do this I would appreciate it!

1 Like

Instead of table.find(ItemsTable, Square.Name).Cost you just need to do this: ItemsTable[Square.Name].Cost.

1 Like

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