Aim punch problem

I’m trying to recreate Aim punch from CSGO but I have this problem

It works find if your standing still, but it doesn’t if your moving

local TweenService = game:GetService("TweenService")
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local OldHealth = Humanoid.Health

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	if Humanoid.Health < OldHealth then
		task.wait(.1)
		for _, v in pairs(Humanoid:GetChildren()) do
			if v.Name == "headshot" then
				local originalCFrame = workspace.CurrentCamera.CFrame
				workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(10),0,0)
				TweenService:Create(workspace.CurrentCamera, TweenInfo.new(.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {CFrame = originalCFrame}):Play()
			end
		end
	end
	OldHealth = Humanoid.Health
end)
1 Like

its because when the tween plays, the camera cframe tween is going back to is the cframe you set before in the variable called “originalCFrame”

instead of tweening the camera cframe, i suggest you create an offset value and you could offset the cameras X rotation by that offset while the camera is moving in a renderstep or something

1 Like

also i see in your games description it says
:warning: High fps (Above 60) will cause extremely high camera recoil, working on a fix. :warning:

a fix for this has been posted before Super high recoil on low FPS - #9 by Moonvane

1 Like

local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local OldHealth = Humanoid.Health

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	if Humanoid.Health < OldHealth then
		for _, v in pairs(Humanoid:GetChildren()) do
			if v.Name == "headshot" then
				local originalCFrame = workspace.CurrentCamera.CFrame
				workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(10), 0, 0)

				for i = 1, 10 do
					RunService.RenderStepped:Wait()
					workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(-1), 0, 0)
				end

				
			end
		end
	end
	OldHealth = Humanoid.Health
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.