Make walk change direction like Eg

I have a character, and when the player is in shift lock. The walk animation doesn’t feel right. I am using Motor6ds and do not know how to rotate the legs based on how the player is moving.

Anyway I can do this? I used this script, but it just spins the character uncontrollably.

while wait() do
	local Look = script.Parent:WaitForChild("HumanoidRootPart").CFrame.LookVector
	local MoveDirection = (script.Parent:WaitForChild("Humanoid").MoveDirection-Look).Unit
	local Dot = Look:Dot(MoveDirection)
	script.Parent["L_UpperLeg"].CFrame *= CFrame.Angles(0,Dot,0)

Here is a gif on what I want.

Sorry for bumping, but does anyone have advice for this? I’m pretty sure many people have done this before. Nothing I search can find it though.

I haven’t actually messed with Motor6D’s that much, so I can’t really help you. However, I will ask, are you trying to go for an inverse kinematics approach?

Yeah somewhat, but its mostly just an animation that should have the legs change and look at the direction you are walking in.

It’s pretty complex for the IK approach, have you seen the community resource posts? The one for R15 and my one for R6? It’s the same system of using IK to make the leg follow a point that rotates in a circle.

What I recorded while studying the R15 resource:

There is also a different system which uses sin on the Y axis to create the circular movement, the previous one uses CFrames to generate the rotation: