So for I while, I’ve been sticking to springs for sway. For a while now, I’ve been looking at @BIackShibe’s work. I really like how he did his weapon sway. It looks like something from a Triple A game.

I was wondering, how could I create an effect like this?

Mhm. I’m wondering how he managed to stop the weapon from going off camera. Notice when I move the mouse all the way to the left, the weapon only goes to a certain point before stopping. Kind of limiting how far the weapon goes.

Have you considered using mouse.Target?, My approach on this would be to allways check the Mouse.Target and change the CFrame for it from there, It also looks like you’re having problems with the Gun when you move yourself…, Is that true?

local lastCameraCF = workspace.CurrentCamera.CFrame;
local mult = 6;
local cfAng = CFrame.Angles
local sin = math.sin
local swayOffset = lastCameraCF
local function sway() --bind this to camera render loop
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF);
local x, y, z = rotation:ToOrientation();
swayOffset = swayOffset:Lerp(cfAng(sin(x)*mult, sin(y)*mult, 0), *.1)
self.viewmodel.HumanoidRootPart.CFrame *= swayOffset;
lastCameraCF = workspace.CurrentCamera.CFrame;
end

local lastCameraCF = workspace.CurrentCamera.CFrame;
local mult = 6;
local cfAng = CFrame.Angles
local sin = math.sin
local swayOffset = lastCameraCF
function handler:update(deltaTime) --bind this to camera render loop
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
end

Ignore main, that’s just used to CFrame the viewmodel properly.

You actually seem pretty close, the difference is in the damping and frequency. Increase the frequency to speed up the movement, and increasing the damping ratio to ≥ 1.

I am pretty close?!? Hmmm. Also what do you mean by frequency. Do you mean like the mousedelta and stuff. I just don’t know how I’m close to achieving that.

(if I didn’t unlock the gun from the center of the screen, the sway would be indentical to yours btw)

use a lot of educated guesses, your main tools being sin(), lerp values (the stuff that makes the gun go down when you look up), CFrame:ToWorldSpace, and CFrame.Angles

That’s a bad way to say the gun just has a box of rotation it revolves around, you just store separate x and y coordinates you influence with mouse delta and clamp to add walls and move the gun based off of

Ahh, I noticed that! So you’re saying that I store x/y coordinates for the box, and don’t let the mousedelta go past that? Or like at least minimize the mousedelta to that?

minimize the coordinates themselves self.directionalModifier = Vector3.new(math.clamp(self.directionalModifier.x, xM, xMX), math.clamp(self.directionalModifier.y, yM, yMX), self.directionalModifier.z)
9123912319th ugly line in the :update() function

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.