Adding recoil on a gun using a contradicting camera loop

I’m trying to add recoil to a gun every time you fire it. However there is a RenderStepped loop that is contradicting the recoil which is used to control the over the shoulder camera of the gun, which always puts the camera back to it’s original position. I want the recoil to tween or lerp and not happen instantly, however I don’t want it to do so all the time because then the camera wouldn’t follow as fast. Currently I’m not sure how to integrate that into my code.

local bloomValue =, 0, 0)

local function cameraBloom(status) -- everytime you fire the gun
	if status == true then
		local randomCFrame =, 1) / 5, math.random(0, 1) / 5, 0)		
		bloomValue = randomCFrame
	elseif status == false then

connection = game:GetService("RunService").RenderStepped:Connect(function()

		startCFrame = * CFrame.Angles(0, math.rad(x), 0) * CFrame.Angles(math.rad(y), 0, 0)

		cameraCFrame = startCFrame:ToWorldSpace(, offset.Y, offset.Z))
		cameraDirection = startCFrame:ToWorldSpace(, offset.Y, -10000)) 

		camera.CFrame =, cameraDirection.Position) * bloomValue
		hrp.CFrame = CFrame.lookAt(hrp.Position,, 0, cameraDirection.Position.Z))

Solved by rewriting most code and switching the camera loop to Humanoid.CameraOffset