Adding a "Walking Sway" for the Framework script my friend provided

Does anybody here know how to add a Walking sway?
The following code already has a Camera Sway system as my friend provided it for me :smiley: Thank you friend if your reading this!

All it needs is a Walking sway, like if you walk. Your viewmodel moves (Just like Phantom Forces)

CODE:

local viewmodel = game.ReplicatedStorage.Viewmodels.Viewmodel:Clone() -- You will need your viewmodel here
viewmodel.Parent = workspace

local lastCamCFrame = CFrame.new()
local swayCFrame = CFrame.new()

workspace.CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()

	local rotation = workspace.CurrentCamera.CFrame:ToObjectSpace(lastCamCFrame)
	local X, Y, Z = rotation:ToOrientation()
	swayCFrame = swayCFrame:Lerp(CFrame.Angles(math.sin(X) * 0.7, math.sin(Y) * 0.7, 0), 0.1)
	lastCamCFrame = workspace.CurrentCamera.CFrame
	viewmodel.CameraBone.CFrame = workspace.CurrentCamera.CFrame * swayCFrame
end)

Are you following This Tutorial ?
Your Code looks similar to this so its an assumption

1 Like

Nope, my friend provided it for me :smiley:

maybe multiply sway cframe by the character velocity magnitude

like this

local v = character.HumanoidRootPart.Velocity.Magnitude
swayCFrame:Lerp(CFrame.Angles((math.sin(X) * 0.7) * v , (math.sin(Y) * 0.7) * v, 0 *  v), 0.1)
1 Like