Object metatable not setting up right

Why am I unable to call kitchen:testing() from a kitchen obj?

local module = {}

local kitchen = {}
kitchen.___index = kitchen
kitchen.Type = "Kitchen"

function kitchen.new()
	local self = {}
	setmetatable(self, kitchen)
	self.Cap = 10
	self.Orders = {}

	function self:queueMeal(meal)
		table.insert(self.Orders, meal)
		print("food cooking")
	end
	return self
end

function kitchen:testing()
	print("hi")
end

function module.newKitchen()
	return kitchen.new()
end

local myKitchen = module.newKitchen()
myKitchen:queueMeal("pizza")

return module

This is what it looks like when I run it. Why isn’t the metastable giving me access to the other functions?

return module

You are returning module, which is an empty table without the functions, and not kitchen.

Why not just export the kitchen object entirely?

In this case, Im using module to generate kitchens. When I get a kitchen obj, I generate it through module.newKitchen()

How does that affect generating multiple objects?
For this case, I think it would be fine but I have similar scripts that I would like to be able to generate multiple items at once

Oh, sorry I just glanced at the script and moved on without actually taking a good look at it. Apologies!

function kitchen.new()
	...
	function self:queueMeal(meal)
	   ...
	end
	return self
end

function kitchen:testing()
	...
end

kitchen:testing() isn’t inside of the object itself, but rather the table kitchen.
You should put the function inside of kitchen.new(), something like this.

function kitchen.new()
	...
	function self:queueMeal(meal)
		...
	end
	
	function self:testing()
		...
	end
	
	return self
end

Then you can just use it as a method of the object.

local KitchenModule = require(...)

local Kitchen= KitchenModule.newKitchen()
Kitchen:testing()

It looks confusing the way you are doing it. I recommend splitting each object into one module script or packing all of them into a dictionary and then returning it rather than having a bunch of helper methods to call constructors.

Update: I took a nap and you’re right I overcomplicated things! Thank you for the help!

I think I get what you’re saying.

Kitchen will be the only object I generate from this script. I was doing it this way so I can call new kitchens like the script above. (for now I only need one but other scripts like Tables or Customers I’ll need multiple) . The objs are stored in another table in another script.

These other mod scripts have functions that affect other instances of the objects. So I wanted them to have “global” variables for this purpose. For instance, customer patience is based on total seated. I can find that but the module tracking that for me is why I wanted to do it.

If I put the respective classes into a dictionary, can I still do that?

Please let me know if I am misunderstanding anything!