Help with camera recoil

So im trying to do a camera recoil by a simple way, rotating the camera 5 degrees up, its fine when you are staying still but when u move ur character the recoil brokens and the camera too.

Script:

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera

function Tween(Object, Info, Table)
	local T = game:GetService("TweenService"):Create(Object,Info,Table)

	return T
end

script.Parent.Activated:Connect(function()
	local char = plr.Character
	local hum = char:WaitForChild("Humanoid")
	local recoil = Tween(cam, TweenInfo.new(0.2,Enum.EasingStyle.Sine), {CFrame = cam.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(2),0,0)})

	script.Parent.Shoot:Play()

	recoil:Play()

	spawn(function()
		script.Parent.Handle.Light.Enabled = true
		wait(.1)
		script.Parent.Handle.Light.Enabled = false
	end)
end)

1 Like