Back again, with yet another problem.

I found that I could make the viewmodel face towards mousedelta/200 and it works quite well.

The issue is, I cannot seem to reverse the sway, meaning that the sway goes reverse to where I look. So I if I were to look to the right, the gun would move to the left.

Example: https://www.youtube.com/watch?v=0p3-P2p--1E

Code:

```
local mult = 6;
local cfAng = CFrame.Angles
local sin = math.sin
function handler:update(deltaTime) --bind this to camera render loop
local lastCameraCF = workspace.CurrentCamera.CFrame;
local swayOffset = lastCameraCF
self.mouseTarget = Player:GetMouse().Target
self.mouseHit = Player:GetMouse().Hit
local mouseDelta = game:GetService("UserInputService"):GetMouseDelta()
if aiming == true then mouseDelta = mouseDelta * 0.1 end
-- print(mouseDelta.x)
local deltaCF = CFrame.new(mouseDelta.x/200, mouseDelta.y/200, 0)
self.unlockedSway = deltaCF
self.deltaTime = deltaTime
Main = Main:Lerp(self.MainCF, 0.2)
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF);
local x, y, z = rotation:ToOrientation();
swayOffset = swayOffset:Lerp(CFrame.Angles(sin(x)*mult, sin(y)*mult, 0), .1)
self.viewmodel.PrimaryPart.CFrame = swayOffset;
lastCameraCF = workspace.CurrentCamera.CFrame;
self.viewmodel.PrimaryPart.CFrame = self.camera.CFrame * Main
--deltaCF = CFrame.new(math.clamp(deltaCF.x, 0, 0), math.clamp(deltaCF.y, 0,0), deltaCF.z)
print(deltaCF.x)
--self.viewmodel.PrimaryPart.CFrame = self.viewmodel.PrimaryPart.CFrame:ToWorldSpace(CFrame.new(deltaCF.Position.x,deltaCF.Position.y,deltaCF.Position.z))
--self.viewmodel.PrimaryPart.CFrame *= CFrame.Angles(0,-self.unlockedSway.Position.x,-self.unlockedSway.Position.y)
--self.viewmodel.PrimaryPart.CFrame = CFrame.new(self.unlockedSway.x,self.unlockedSway.y,self.unlockedSway.z)
--self.viewmodel.PrimaryPart.CFrame *= CFrame.Angles(-deltaCF.Position.y,-deltaCF.Position.x,-deltaCF.Position.z)
self.viewmodel.PrimaryPart.CFrame = CFrame.new(self.viewmodel.PrimaryPart.Position, self.unlockedSway.Position)
end
```

Changing mousedelta to negative doesn’t seem to do anything.

Edit: I haven’t clamped stuff yet, just trying to “unlock” the gun.