local Player = game.Players.LocalPlayer
local Character = Player.Character
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local AnimationsFolder = script:WaitForChild("Animations")
local AnimationsTable = {
["WalkForward"] = Humanoid:LoadAnimation(AnimationsFolder.WalkForward),
["WalkLeft"] = Humanoid:LoadAnimation(AnimationsFolder.WalkLeft),
["WalkRight"] = Humanoid:LoadAnimation(AnimationsFolder.WalkRight),
}
for _, Animation in AnimationsTable do
Animation:Play(0,0.01,0)
end
Runservice.RenderStepped:Connect(function()
local DirectionOfMovement = HumanoidRootPart.CFrame:VectorToObjectSpace(HumanoidRootPart.AssemblyLinearVelocity)
local Forward = math.abs(math.clamp(DirectionOfMovement.Z / Humanoid.WalkSpeed, -1,-0.001))
local Backwards = math.abs(math.clamp(DirectionOfMovement.Z / Humanoid.WalkSpeed, 0.001,1))
local Left = math.abs(math.clamp(DirectionOfMovement.X / Humanoid.WalkSpeed, 0.001,1))
local Right = math.abs(math.clamp(DirectionOfMovement.X / Humanoid.WalkSpeed, -1,-0.001))
local SpeedUnit = (DirectionOfMovement.Magnitude/Humanoid.WalkSpeed)
if DirectionOfMovement.Z/Humanoid.WalkSpeed < 0.1 then
AnimationsTable.WalkForward:AdjustWeight(Forward)
AnimationsTable.WalkRight:AdjustWeight(Right)
AnimationsTable.WalkLeft:AdjustWeight(Left)
AnimationsTable.WalkForward:AdjustSpeed(SpeedUnit)
AnimationsTable.WalkRight:AdjustSpeed(SpeedUnit)
AnimationsTable.WalkLeft:AdjustSpeed(SpeedUnit)
else
AnimationsTable.WalkForward:AdjustWeight(Backwards)
AnimationsTable.WalkRight:AdjustWeight(Left)
AnimationsTable.WalkLeft:AdjustWeight(Right)
AnimationsTable.WalkForward:AdjustSpeed((SpeedUnit) * -1)
AnimationsTable.WalkRight:AdjustSpeed((SpeedUnit) * -1)
AnimationsTable.WalkLeft:AdjustSpeed((SpeedUnit) * -1)
end
end)```