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 = hrp.Position+Vector3.new(0,0,direction)
hrp.CFrame = CFrame.new(hrp.Position,newPosition)
end
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 = CFrame.new(stageMiddlePart.CFrame.X, hrp.CFrame.Y, hrp.CFrame.Z)
end
end
end