Attempt to call missing method 'Click' of table

I was tryna use Click Function after a button activated but I got the error on the title
so I Don’t know how to describe the problem really I am new to SetMetaTable and MetaTables
I just want to know how to get rid of this error and why it happened

local Shop = {}
Shop.__Index = Shop

function Shop:Click()
	print("clicked")
	print(self)
end
function Shop.new(shop: string)
	CurrentShop = shop
	print("Tanratointiano")
	ShowInfoFrame(false)
	local list = if shop == "Scythe" then toolConfig elseif shop =="DNA" then DNAConfig else RankConfig

	for _, toolTable in ipairs(list) do
		local object = setmetatable({}, Shop)
		object.Name = toolTable.ID
		object.Stat = if toolTable.Stat then toolTable.Stat else 0  

		local ItemClone = ItemTemplate:Clone()
		ItemClone.Parent = Container

		object.TemplateButton = ItemClone
		print(Shop)
		print(shop)

		if shop == "Scythe" then
	         	object.TemplateButton.Lock.Visible = false
			object.TemplateButton.ImageLabel.Visible = true

		else 
                        object.TemplateButton.Lock.Visible = true
			object.TemplateButton.ImageLabel.Visible = false
		end

		object.TemplateButton.MouseButton1Click:Connect(function(player)
                        print(object)
			print(Shop)
			object:Click() --Error is here
		end)	
	end
end
return Shop

Metamethods are case-sensitive; it’s __index

2 Likes

Ow!
I didn’t notice it… Thanks really I was about the rewrite whole code from beginning

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