I have recently been trying to make a weapon sway system for my game. I’ve come SOOO CLOSE to getting it, but none the less It won’t work.
The original script that somewhat works is this:
local Position = Vector3.new(script.X.Value + CameraOffset.X + WeaponOffset.X,script.Y.Value + CameraOffset.Y + WeaponOffset.Y,script.Z.Value + CameraOffset.Z + WeaponOffset.Z)
WeaponModel:SetPrimaryPartCFrame(WeaponModel.PrimaryPart.CFrame:Lerp(Camera.CFrame * CFrame.new(Position),.5))
This works, but not how I want it to. It sways not only the rotation, but also the position. What I want is for it to ONLY sway the rotation, but I’ve had some troubles with separating and reconstructing the 2.
Here is what I have so far, but It does not work.
local PositionOffset = Vector3.new(script.X.Value + CameraOffset.X + WeaponOffset.X,script.Y.Value + CameraOffset.Y + WeaponOffset.Y,script.Z.Value + CameraOffset.Z + WeaponOffset.Z)
local Temp = Camera.CFrame * CFrame.new(PositionOffset)
WeaponModel:SetPrimaryPartCFrame(CFrame.new(Temp.Position))
local Rx,Ry,Rz = (Camera.CFrame * CFrame.new(PositionOffset)):ToOrientation()
--WeaponModel:SetPrimaryPartCFrame(WeaponModel.PrimaryPart.CFrame:Lerp(CFrame.new(CFrame.fromOrientation(Rx,Ry,Rz) + WeaponModel.PrimaryPart.CFrame.Position)),.5)
--WeaponModel:SetPrimaryPartCFrame(WeaponModel.PrimaryPart.CFrame * CFrame.fromOrientation(Rx,Ry,Rz))
WeaponModel:SetPrimaryPartCFrame(WeaponModel.PrimaryPart.CFrame:Lerp(WeaponModel.PrimaryPart.CFrame * CFrame.fromOrientation(Rx,Ry,Rz),.5))
Does anyone know how I could do this?