Using CameraOffset while changing Camera CFrame

  1. What do you want to achieve? Keep it simple and clear!
    I use a Lock-On system, where you can lock your camera on an enemy, but i also want to add a Camera Shake to the game, but these are not working well together.

  2. What is the issue? Include screenshots / videos if possible!
    If the Lock-On is on, the Camera Shake does not work.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did not found anyone who had the same problem, but i tried using the camera’s CFrame instead of the CameraOffset on the Camera Shake, but i could not make it work.

I basically need a way to make these two work, the Lock-On script changes the camera CFrame on every RenderStep, and it does not work with the CameraShake, that changes the camera Offset randomly to create a “shake” effect.

The Lock-On system:

runService.RenderStepped:Connect(function()
	if Target and dead == false then
		local newPos = CFrame.new(char.HumanoidRootPart.Position, Vector3.new(Target.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,Target.HumanoidRootPart.Position.Z))
		char.HumanoidRootPart.CFrame = newPos
		
		local CamPos = CFrame.new(char.HumanoidRootPart.Position, Target.PrimaryPart.Position)*gameModule.GameData["LockCamPos"].Position
		workspace.Camera.CameraType = "Scriptable"
		workspace.Camera.CFrame = CFrame.new(CamPos,Target.PrimaryPart.Position)
	else
		ui.Parent = nil
		Target = nil
		workspace.Camera.CameraType = "Custom"
	end
end)

And, the camera shake:

local function CameraShake(force, Time, camera)	
	local Start = tick()
	repeat
		print(1)
		wait()
		local End = tick()

		local x = math.random(-100,100) / force
		local y = math.random(-100,100) / force
		local z = math.random(-100,100) / force


		char.Humanoid.CameraOffset = Vector3.new(x,y,z)
	until End - Start >= Time
	char.Humanoid.CameraOffset = Vector3.new(0,0,0)
end

game.ReplicatedStorage.Remotes.CameraShake.OnClientEvent:Connect(function(force, Time)
	local camera = workspace.CurrentCamera
	
	CameraShake(force, Time, camera)
end)