How can I make these 2 modules share some methods?

I have 2 module scripts one for the player and one for my AI and there are 2 methods that they’re both gonna use obviously Lua doesn’t really have classes or inheritance so what’s the alternative? Would I just require the player module in the AI module and call the methods? I’m using Knit so perhaps there’s even something built into Knit I’m not aware of?

function PlayerController:FaceOpponent()
	if state.current == "air" then return end
	local target = CS:GetTagged("Opponent")[1].HumanoidRootPart or CS:GetTagged("Middle")[1]
	if not target then return end 

	local hrp = self:GetCharacter():WaitForChild("HumanoidRootPart")

	local newDirection = math.floor(target.CFrame.Z - hrp.CFrame.Z)
	newDirection = math.sign(math.sign(newDirection) + 0.5)
	direction = newDirection

	local newPosition =,0,direction)
	hrp.CFrame =,newPosition)

function PlayerController:LockZAxis()
	local stageMiddlePart = CS:GetTagged("Middle")[1]
	local hrp = self:GetCharacter():WaitForChild("HumanoidRootPart")
	if stageMiddlePart then
		if hrp.CFrame.X ~= stageMiddlePart.CFrame.X then
			hrp.CFrame =, hrp.CFrame.Y, hrp.CFrame.Z)		

What do you mean by share some methods? Is the AI being handled by the client?

Do you mean that self:GetCharacter() the player and the AI? Also about this question:

Lua does have classes, is a class.

No Lua doesn’t. That’s a Roblox-only extension of the language.

Well technically this is the only way of creating a class .new function.

You can achieve inheritance by taking advantage of some metatable magic as explained in the “What about inheritance?” section of this article.
This should allow you to create a base class that contains a common method that your sub-classes can feed off of.

Well the AI and player are gonna have some things in common in other languages I could just make a class called Character or something and do inheritance or even use composition, but I don’t think that’s possible in roblox?