Lerp Camera on Button1Down

I am trying to make weapon recoil, it works right now but it is really rough because it is just simply multiplying camera cframe by offset cframe. I want to make it smoother by lerping the camera instead of just multiplying it but I could not come out with any solutions.

code here:

workspace.currentcamera.cframe *= workspace.currentcamera.cframe:lerp(recoilOffset,0.1)

the code is the closest solution to what im trying to achieve

The problem is that lerp is meant to be called every tick to move it closer every time.

You could either:
Create a for-wait loop.

Or better yet, use Tweens:

local TweenService = game:GetService("TweenService")

	local tween = TweenService:Create(workspace.CurrentCamera, TweenInfo.new(0.1), {CFrame = recoilOffset})

Just as an example, but you should probably look at the link for Tweens because there is much more. (EasingStyles, etc.)

lol i did this a while ago and it didn’t work because i forgot to play it, thanks :smiley:

:Lerp() is used to interpolate between two properties (values) using a specified fraction alpha value (a value between 0 and 1 inclusively which represents a percentage from 0% to 100% of which to aim towards).