so i originally made a post about this yesterday asking the same thing but i didnt really explain it correctly. So i have a Gun Recoil System and a Crouch system which both use Camera Offset. I have a function connect to RunService that updates the XYZ variable i have for the Camera Offset heres a video of my problem video what happens is that when i shoot without crouching the recoil is no problem but when i do crouch the recoil makes me go back up to the original camera offset then do recoil
i hope this makes sense
repeat wait() until x2 ~= nil
local OffsetP = {CameraOffset = Vector3.new(x2,y2 + 0.08,z2 - 0.04)}
local Infor = TweenInfo.new(0.1, Enum.EasingStyle.Circular, Enum.EasingDirection.In)
local OffSetd = game:GetService("TweenService"):Create(Character.Humanoid, Infor, OffsetP)
local x = viewModel.Classic.Bottom.Top.C0.X
local y = viewModel.Classic.Bottom.Top.C0.Y
local z = viewModel.Classic.Bottom.Top.C0.Z
local Properties = {C0 = CFrame.new(0.5,y,z)}
local Info = TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local Back = game:GetService("TweenService"):Create(viewModel.Classic.Bottom.Top, Info, Properties)
local lol = {CameraOffset = Vector3.new(x2,y2 - 0.08,z2 + 0.04)}
local ll = TweenInfo.new(0.1, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
local Anim = game:GetService("TweenService"):Create(Character.Humanoid, ll, lol)
local Properties2 = {C0 = CFrame.new(x,y,z)}
local Info2 = TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local Forward = game:GetService("TweenService"):Create(viewModel.Classic.Bottom.Top, Info2, Properties2)
RunService.RenderStepped:Connect(function()
lol = {CameraOffset = Vector3.new(Character.Humanoid.CameraOffset.X,Character.Humanoid.CameraOffset.Y - 0.08,Character.Humanoid.CameraOffset.Z + 0.04)}
OffsetP = {CameraOffset = Vector3.new(Character.Humanoid.CameraOffset.X,Character.Humanoid.CameraOffset.Y + 0.08,Character.Humanoid.CameraOffset.Z - 0.04)}
end)
Mouse.Button1Down:Connect(function()
if CanShoot == true and shooting == false then
if not Forward.Completed then
Forward:Stop()
end
shooting = true
OffSetd:Play()
CanShoot = false
Vandal.Fire:Play()
Back:Play()
wait(0.1)
Anim:Play()
Forward:Play()
wait(firerate)
CanShoot = true
shooting = false
end
end)
-- Crouch --
local anim = script.Crouch
local play = Character:WaitForChild("Humanoid"):LoadAnimation(anim)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
IsCrouched = true
Character.Humanoid.WalkSpeed = 8
local Properties = {CameraOffset = Vector3.new(x2,y2 - 1,z2)}
local Info = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local T = game:GetService("TweenService"):Create(Character.Humanoid, Info, Properties)
T:Play()
play:Play()
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
IsCrouched = false
Character.Humanoid.WalkSpeed = 12
local Properties = {CameraOffset = Vector3.new(x2,y2 + 1,z2)}
local Info = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local T = game:GetService("TweenService"):Create(Character.Humanoid, Info, Properties)
T:Play()
play:Stop()
end
end)
