Ok so I tried a bunch of methods I came up with but what happens is for some reason the lerp doesn’t get limited. Here is the original localscript body lerp which works perfectly.
local run_service = game:GetService("RunService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local humanoid_root_part = char:FindFirstChild("HumanoidRootPart")
local torso = char:FindFirstChild("Torso")
local root_joint = humanoid_root_part.RootJoint
local left_hip = torso["Left Hip"]
local right_hip = torso["Right Hip"]
local function lerp(a, b, c)
return a + (b - a) * c
end
local Force = nil
local Direction = nil
local value_1 = 0
local value_2 = 0
local root_joint_C0 = root_joint.C0
local left_hip_C0 = left_hip.C0
local right_hip_C0 = right_hip.C0
local remote = game.ReplicatedStorage.PLerp
run_service.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 = humanoid_root_part.Velocity * Vector3.new(1,0,1)
if Force.Magnitude > 0.001 then
--> This represents the direction
Direction = Force.Unit
value_1 = humanoid_root_part.CFrame.RightVector:Dot(Direction)
value_2 = humanoid_root_part.CFrame.LookVector:Dot(Direction)
else
value_1 = 0
value_2 = 0
end
root_joint.C0 = root_joint.C0:lerp(root_joint_C0 * CFrame.Angles(math.rad(value_2 * 14), math.rad(-value_1 * 22), 0), 0.2)
left_hip.C0 = left_hip.C0:lerp(left_hip_C0 * CFrame.Angles(math.rad(value_1 * 10), 0, 0), 0.2)
right_hip.C0 = right_hip.C0:lerp(right_hip_C0 * CFrame.Angles(math.rad(-value_1 * 10), 0, 0), 0.2)
end)