Im using a tween effect to create a recoil for my gun script and the output says that its working but no matter how I tweak the values it never actually does anything.
``local function ApplyRecoil()
local tweenInfo = TweenInfo.new(
recoilDuration, -- Duration
Enum.EasingStyle.Sine, -- EasingStyle
Enum.EasingDirection.InOut, -- EasingDirection
0, -- Times to repeat
true, -- Reverses
0 -- Delay
)
local originalCFrame = handle.CFrame
local recoilCFrame = originalCFrame * CFrame.Angles(math.rad(-recoilAmount), 0, 0)
print("Applying recoil: Original CFrame: ", originalCFrame, " Recoil CFrame: ", recoilCFrame)
local recoilTween = tweenService:Create(handle, tweenInfo, {CFrame = recoilCFrame})
recoilTween:Play()
recoilTween.Completed:Connect(function()
print("Recoil completed, returning to original CFrame")
local returnTween = tweenService:Create(handle, tweenInfo, {CFrame = originalCFrame})
returnTween:Play()
end)
end
--stuff
tool.Activated:Connect(function()
if not enabled then return end
enabled = false
fire:FireServer(mouse.Hit)
ApplyRecoil() -- Apply recoil effect
wait(fireRate.Value)
enabled = true
end)``