So I recentlty started working on a Viewmodel and wanted to add Sway Effect
The problem is I don’t have any errors and the Sway Effect is not applying to the model
Code :
coroutine.wrap(function()
RunService:BindToRenderStep("CameraRender", Enum.RenderPriority.Camera.Value + 1, function()
local lastCFrame = camera.CFrame
local Orientation = camera.CFrame:ToObjectSpace(lastCFrame)
local x, y, z = Orientation:ToOrientation()
SwayCFrame = SwayCFrame:Lerp(CFrame.new(math.sin(x)*6, math.sin(y)*6, 0), 0.1)
lastCFrame = camera.CFrame
end)
end)()
RunService.RenderStepped:Connect(function(deltaTime)
if WeaponViewmodel then
WeaponViewmodel:SetPrimaryPartCFrame(
camera.CFrame *
MainCFrame *
SwayCFrame *
BobbleCFrame *
AimingCFrame
)
if Aiming then
AimingCFrame = AimingCFrame:Lerp(WeaponData.AimingCFrame, .5)
else
AimingCFrame = AimingCFrame:Lerp(CFrame.new(), .5)
end
end
end)
Thanks for help !