--local script--
local run=game:GetService'RunService'
local cas=game:GetService'ContextActionService'
local recoilCF=CFrame.Angles(0,0,0)
local cam=workspace.CurrentCamera
run.RenderStepped:Connect(function()
local smoothSpeed=.1
recoilCF=recoilCF:Lerp(CFrame.Angles(0,0,0),smoothSpeed)
--[[ smoothSpeed for smoothness, more precisely for smoothness after the shot
Increase the value of smoothSpeed to make the smoothness fast and
vise versa
--]]
cam.CFrame*=recoilCF
end)
function recoil()
local strength=1
local speed=.8
recoilCF=recoilCF:Lerp(CFrame.Angles(0,strength,0),speed)
--[[ return recoil if you want
spawn(function() -- not to overlap
task.wait(.2)
recoilCF=recoilCF:Lerp(CFrame.Angles(0,-strength,0),speed)
end)
--]]
end
I tried to add :
local physics = game.Workspace.CurrentCamera:GetPropertyChangedSignal(“CFrame”)
physics:Connect(function()
game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame:lerp(pos, 0.5)
end)
It works, but it takes a while to get back to the original position and it’s very slow.
The weird thing is that I used to use this code:
local physics = game.Workspace.CurrentCamera:GetPropertyChangedSignal(“CFrame”)
physics:Connect(function()
game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame:lerp(pos, 0.5)
end)