I am trying to get my view model to have smooth sway from moving camera any direction instead of depth so front and back.

The script dose not look smooth and kind of glitched when moving.

when i put the last value to 1 it makes the model still but i want to have sway is there an alternate method for this sway with the camera or is there a fix for this that i dont know of.
i am also trying to not expose my hole script to the world so i slimmed it down.

This is under RenderStepped atm.

Setprimarypartcframe is not the best solution but its good for me for now until i figure a way to do all of this in a different way.

ive tried separating getprimarypartcframe and putting it into heartbeat but it dose not seem to solve it. i looked all over the forums and google and got no solution.

Your issue is that you are using lerp() to place your model at the camera position. Because lerp() isnāt an instant snap, your model lags behind when the camera moves. To fix your unwanted behavior, stop using lerp() and just snap your viewmodelās position to the cameraās position.

i couldnt get what they said to work but it did fix the thing of using Primarypartcframe

but the script when i edit it dosent seem to work im unsure what they mean by camera delta but this is what i got so far

Lcamera is the camera position hinting L for LocalCamera and the ViewmodelArms is the rig. for swayoffsetting i tryed to manually specify the location the the primary part incase it wasnt reading it but i get a error saying

Cframe is not a Valid member of partā¦

local mult = 1

function renderloop() --bind this camera render loop

local rotation = Lcamera.CFrame:toObjectSpace(Lcamera.CFrame) --get cframe delta.

local xs,ys,zs = rotation:ToOrientation() --Iām sure there are better ways to get rotation but this will work for now.

local swayOffseting = Arms.PrimaryPart.Cframe

local swayOffset = swayOffseting:Lerp(CFrame.Angles(math.sin(xs)*mult,math.sin(ys)*mult,0), 0.1) --calculate the sway using SIN

ViewmodelArms.CFrame = ViewmodelArms.CFrame * swayOffset --apply the sway

Also if you are wondering in this case āCFrame deltaā is CFrame:ToObjectSpace, were the CFrame is transformed from Object to World space. Equivalent to [CFrame:inverse() * cf] ( straight from the wiki), then by inserting the last camera cframe (parameter) they are getting the

im unsure on how to fix this but i get a error swayOffset is a nil value and on that post it dose not tell what it has because it cant be call its self it would come nil how would i solve this?

local mult = 1
function renderloop() --bind this camera render loop

local rotation = ViewmodelArms.PrimaryPart.CFrame:toObjectSpace(Lcamera.CFrame) --get cframe delta.

local x,y,z = rotation:ToOrientation() --Iām sure there are better ways to get rotation but this will work for now.

swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1) --calculate the sway using SIN

ViewmodelArms.PrimaryPart.CFrame = ViewmodelArms.PrimaryPart.CFrame * swayOffset --apply the sway

Lcamera.CFrame = workspace.CurrentCamera.CFrame --update the last cframe

This is the line sorry to bother a lot but Iāve been at doing the rig and model for a month with not much progress.

The rig literally spazzing.
Iām guessing I have to define swayOffset to something but Iām unsure what to set to I tried doing empty cframe and number 0 and also tried setting it to currentcamera.

swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1) --calculate the sway using SIN

as a recommendation for now i would look for some more methods and solutions on the devfourm(or anywhere) and research a little on some cframing and tweening, if you have any questions i would be glad to try and answer, when i can.
iāll also do some of my own researching and testing at some point(if you or someone else hasnāt already solved this issue), and ill let you know what i find or recommendā¦

i have been referencing the first person element community tutorial but broke most of time and it didnt have the method of animating i wanted. i will just have to research even more or figure out a method. so i made it more easy for me to understand.

I have been researching about a week and a half and have not been able to fix it but lerp the item to the location of the camera wich is very jittery/laggy. you can visit the place to see how it looks.

function renderloop()

lastCameraCF = Lcamera.CFrame

local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF) --get cframe delta.
local x,y,z = rotation:ToOrientation() --I'm sure there are better ways to get rotation but this will work for now.
local Location = ViewmodelArms.PrimaryPart.CFrame
-- local swayOffset = ViewmodelArms.PrimaryPart.CFrame
-- swayOffset = CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0) --calculate the sway using SIN
-- ViewmodelArms.PrimaryPart.CFrame = lastCameraCF * swayOffset
ViewmodelArms.PrimaryPart.CFrame = lastCameraCF:Lerp(ViewmodelArms.PrimaryPart.CFrame * CFrame.new(OffsetAnimationSines)* CFrame.Angles(animationsines),mult/1.5)
lastCameraCF = Lcamera.CFrame --update the last cframe