Hey devs,
I was recently given this first-person shooter script that applies a sway effect to the viewmodel, but I’m not too sure how it works. I added comments to the script to explain what I understand and what I don’t
local rotation = workspace.CurrentCamera.CFrame:ToObjectSpace(lastCamCFrame)
local X, Y, Z = rotation:ToOrientation() -- I know what this does
swayCFrame = swayCFrame:Lerp(CFrame.Angles(math.sin(X) * 0.7, math.sin(Y) * 0.7, 0), 0.1) -- I know how :Lerp() works
lastCamCFrame = workspace.CurrentCamera.CFrame -- I understand this
viewmodel.CamPart.CFrame = workspace.CurrentCamera.CFrame * swayCFrame -- I understand this
I basically just don’t understand the third line, and mainly the math.sin part, as I can’t seem to figure out how that works.