How do I add camera sway?

You can use UserInputService:GetMouseDelta() to get mouse delta, use the X direction of the mouse delta for camera turn.

here is a sample code I made

--Services
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

-- Variables
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
local Turn = 0

-- Functions
local Lerp = function(a, b, t)
	return a + (b - a) * t
end;

-- Main
LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson -- First Person

RunService:BindToRenderStep("CameraSway", Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
	local MouseDelta = UserInputService:GetMouseDelta()
	
	Turn = Lerp(Turn, math.clamp(MouseDelta.X, -6, 6), (15 * deltaTime))
	
	Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, math.rad(Turn))
end)
23 Likes