local E=Players.LocalPlayer local S=script.Parent local c=S:WaitForChild("\072\117\109\097\110\111\105\100")local o=S.HumanoidRootPart local C=S.Torso local f=o.RootJoint local X=C["\076\101\102\116 \072\105\112"]local O=C["\082\105\103\104\116 \072\105\112"]local function j(E,S,c)return E+(S-E)*c end local r=nil local H=nil local n=0 local v=0 local s=f.C0 local w=X.C0 local l=O.C0 RunService.RenderStepped:Connect(function()r=o.Velocity*Vector3.new(1,0,1)if r.Magnitude>2 then H=r.Unit n=o.CFrame.RightVector:Dot(H)v=o.CFrame.LookVector:Dot(H)else n=0 v=0 end f.C0=f.C0:Lerp(s*CFrame.Angles(math.rad(v*10),math.rad(-n*10),0),.2)X.C0=X.C0:Lerp(w*CFrame.Angles(math.rad(n*10),0,0),.2)O.C0=O.C0:Lerp(l*CFrame.Angles(math.rad(-n*10),0,0),.2)end)

local Player = Players.LocalPlayer
local Character = script.Parent
local Humanoid = Character:WaitForChild"Humanoid"

local HumanoidRootPart = Character.HumanoidRootPart
local Torso = Character.Torso

local RootJoint = HumanoidRootPart.RootJoint
local LeftHipJoint = Torso["Left Hip"]
local RightHipJoint = Torso["Right Hip"]

local function Lerp(a, b, c)
	return a + (b - a) * c
end

local Force = nil
local Direction = nil
local Value1 = 0
local Value2 = 0

local RootJointC0 = RootJoint.C0
local LeftHipJointC0 = LeftHipJoint.C0
local RightHipJointC0 = RightHipJoint.C0

RunService.RenderStepped:Connect(function()
	--> To get the force, we multiply the velocity by 1,0,1, we don't want the Y value so we set y to 0
	Force = HumanoidRootPart.Velocity * Vector3.new(1,0,1)
	if Force.Magnitude > 2 then
		--> This represents the direction
		Direction = Force.Unit	
		Value1 = HumanoidRootPart.CFrame.RightVector:Dot(Direction)
		Value2 = HumanoidRootPart.CFrame.LookVector:Dot(Direction)
	else
		Value1 = 0
		Value2 = 0
	end
	
	--> the values being multiplied are how much you want to rotate by
	
	RootJoint.C0 = RootJoint.C0:Lerp(RootJointC0 * CFrame.Angles(math.rad(Value2 * 10), math.rad(-Value1 * 10), 0), 0.2)
	LeftHipJoint.C0 = LeftHipJoint.C0:Lerp(LeftHipJointC0 * CFrame.Angles(math.rad(Value1 * 10), 0, 0), 0.2)
	RightHipJoint.C0 = RightHipJoint.C0:Lerp(RightHipJointC0 * CFrame.Angles(math.rad(-Value1 * 10), 0, 0), 0.2)
end)
