I’ve found a camera swaying script from this DevForum post and I’m wondering on how would I optimize/reformat it to include other stuff such as viewmodels, camera bobbing, etc? (Basically, how would I add other camera/viewmodel-related code inside of it while feeling natural in a way?)
--[[SERVICES]]--
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
--[[VARIABLES]]--
local CurrentCamera = game.Workspace.CurrentCamera
local Turn = 0
--[[LERPING FUNCTION]]--
local function Lerp(A, B, T)
return A + (B - A) * T
end
--[[MAIN/CAMERA SWAYING]]--
RunService:BindToRenderStep("CameraSway", Enum.RenderPriority.Camera.Value + 25, function(deltaTime)
local MouseDelta = UserInputService:GetMouseDelta()
Turn = Lerp(Turn, math.clamp(MouseDelta.X, -4, 3), (15 * deltaTime))
CurrentCamera.CFrame = CurrentCamera.CFrame * CFrame.Angles(0, 0, math.rad(Turn))
end)