Camera Shake affects Character movement

I am currently making a supposed remaster of Hotline Roblox. Going slow but steady.

I’ve made a top down view camera, it uses TweenService.
The character also follows the cursor.

However, when I try to use EZ Camera Shake ported to roblox and add it to my gun for example, it starts to make jerky movements to the character, as seen here:

I think it is something with my camera script rather than the actual module, however, I have no clue what.

Here’s bits from the top down camera code to give a better idea:

local function getMousePos()
	local mouseDirection = CFrame.lookAt(camera.CFrame.Position, mouse.Hit.Position).LookVector.Unit
	local cameraDistance = (camera.CFrame.Position - Root.Position).Magnitude
	local mousePosition = (camera.CFrame.Position + mouseDirection * cameraDistance)
	return Vector3.new(mousePosition.X, character.Head.Position.Y, mousePosition.Z)
end

local function getLookDirection()
	return (getMousePos() - character.Head.Position).Unit
end

-- main function
local function TweenCamera(dt)
	if character and character:FindFirstChild("Head") then
		if character:FindFirstChild("Humanoid").Health > 0 then
			if CameraEnabled.Value then
				ctrlDown = false

				local lookDirection = getLookDirection()
				local targetCFrame = CFrame.new(Root.Position + Vector3.new(-0.6, Offset.Value, 0), Root.Position) + lookDirection * LookValue.Value

				local Tween = TS:Create(
					camera,
					TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{CFrame = targetCFrame}
				)

				Tween:Play()
				ctrlDown = false
			else
			end
		end
	end
end

-- slightly move the camera towards the walk position
Humanoid.Changed:Connect(function(Property)
	if Property == "MoveDirection" then
		local Tween = TS:Create(
			DirValue,
			TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
			{Value = Humanoid.MoveDirection * 1.3}
		)

		Tween:Play()
	end
end)

RS.RenderStepped:Connect(function()
	camera.FieldOfView = FieldOfView
	if character and character:FindFirstChild("Head") then
		game:GetService("SoundService"):SetListener(Enum.ListenerType.ObjectCFrame, character.Head)
		camera.CameraType = Enum.CameraType.Scriptable
	end
end)

RS.RenderStepped:Connect(TweenCamera)

-- move player to the mouse position
RS.RenderStepped:Connect(function(dt)
	if character then
		if character:FindFirstChild("HumanoidRootPart") then
			if character:FindFirstChild("Humanoid").Health > 0 then
				if CanLook.Value then
					Humanoid.AutoRotate = false
					local pos = player:GetMouse().Hit.Position
					local lookToPosVector = Vector3.new(pos.X, Root.Position.Y, pos.Z)
					Root.CFrame = Root.CFrame:Lerp(CFrame.lookAt(Root.Position, lookToPosVector),dt * 15)
				else 
				end
			end
		end
	end
end)
2 Likes

I’m pretty sure it’s moving the gun, Roblox uses welds to attach tools to characters so it would also move your character.