the last line under the camera module comment is setting the camera’s new cframe with no rotation
Im also changing the cameraRotation variable by calling a function inside the wall run script cameraService:SetRotation(CFrame.Angles(0, 0, math.rad(45))) and cameraService:SetRotation(CFrame.Angles(0, 0, 0))
sorry if it looks like alot
-- // Wall Run Script
local currentRot = camera.CFrame * CFrame.Angles(0, 0, math.rad(lookDir * cameraRotation))
local rx, ry, rz = currentRot:ToOrientation()
local rotClamp = math.clamp(math.deg(rz), -cameraRotation, cameraRotation)
local newCFrame = CFrame.fromOrientation(rx, ry, math.rad(rotClamp))
--camera.CFrame = camera.CFrame:Lerp(newCFrame, rotationSpeed * deltaTime)
local _, _, z = rotationCFrame:ToOrientation()
rotationCFrame = CFrame.fromEulerAnglesYXZ(rx, ry, z)
rotationCFrame = rotationCFrame:Lerp(newCFrame, math.min(rotationSpeed * deltaTime, 1))
camera.CFrame = CFrame.new(camera.CFrame.Position) * rotationCFrame
-- // Camera Module
local cameraRotation = CFrame.Angles(0, 0, 0)
local rotationSpeed = 5
camera.CFrame = CFrame.lookAt(cameraPosition, cameraFocus)
You should be doing the lerping and setting of the camera roll inside the camera script. The structure should go something like this.
-- Wall run script
local CameraModule = require(--[[This is the camera module path]])
RunService.Heartbeat:Connect(function()
-- Get the target rotation here ^
CameraModule:SetRoll(rotClamp)
end)
-- Stop running
CameraModule:SetRoll(0)
-- Camera module
function CameraModule:SetRoll(value: number)
self.targetRoll = value
end
-- Update loop
local _, _, z = camera.CFrame:ToOrientation()
local roll = CFrame.Angles(0, 0, z)
local targetRoll = roll:Lerp(CFrame.Angles(0, 0, math.rad(self.targetRoll)), math.min(rotationSpeed * deltaTime, 1)
camera.CFrame = CFrame.lookAt(cameraPosition, cameraFocus) * targetRoll