Hello, what would be the best way make a viewmodel sway smoothly while walking?
Put this script in starter character scripts
make sure its a local script.
this uses CameraOffset
local runService = game:GetService(“RunService”)
local character = script.Parent
local humanoid = character:WaitForChild(“Humanoid”)
function updateSwayEffect()
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then – we are walking
local SwayX = math.cos(currentTime * 10) * .35
local SwayY = math.abs(math.sin(currentTime * 10)) * .35
local Sway = Vector3.new(SwayX, SwayY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(Sway, .25)
else -- we are not walking
humanoid.CameraOffset = humanoid.CameraOffset * .75
end
end
runService.RenderStepped:Connect(updateSwayEffect)
Well I’ve already figured out a solution but thanks anyway
I should’ve probably searched before asking