I’m trying to edit the CameraModule to simplify the code to do what I need it to do, which is follow the character with a specific rotation and offset, however I cannot seem to figure out why the Module’s :Update() function isn’t firing every frame, despite the rest of the code working as expected. Code and file is provided below
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Utilities = require(ReplicatedStorage:WaitForChild("Utilities"))
local Camera = game.Workspace.CurrentCamera
local CameraOffset = Vector3.new(0,0, 10)
local CameraRotation = Vector3.new(90, 0, 0)
local Character
local CameraModule = {}
CameraModule.__index = CameraModule
function CameraModule.new()
local self = setmetatable({},CameraModule)
self.CharacterAdded = Utilities.CreateNewEvent("CharacterAdded") -- Instance
self.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
print(NewCharacter, typeof(NewCharacter))
end)
return self
end
function CameraModule:Update(TimeElapsed)
print(1, TimeElapsed)
if Character and Character.HumanoidRootPart ~= nil then
local HumanoidRootPart = Character.HumanoidRootPart
local CF = CFrame.new(HumanoidRootPart.Position + CameraOffset)
CF = CF * CameraRotation
Camera.CFrame = Camera.CFrame:Lerp(CF, TimeElapsed)
end
end
return CameraModule.new()
TPS.rbxl (261.7 KB)