local recoil = CFrame.new()
local Recoiling = false
local function applyRecoil()
Recoiling = true
local con; con = game["Run Service"].RenderStepped:Connect(function()
-- Generate random recoil values
local randomX = math.random(1.5, 3)
local randomY = ((math.random(1, 2) == 1) and 1.5) or -1.5
-- Define the goal rotation for recoil
local goal = CFrame.Angles(math.rad(randomX), math.rad(randomY), 0)
-- Apply recoil
recoil = recoil:Lerp(goal, 0.05)
Camera.CFrame *= recoil
task.wait(0.1)
-- Reverse recoil by interpolating back to the original CFrame
local reverseGoal = CFrame.new()
recoil = recoil:Lerp(reverseGoal, 0.05)
Camera.CFrame *= recoil
task.wait(0.1)
if (recoil == reverseGoal) then
Recoiling = false
con:Disconnect()
end
end)
end
applyRecoil()