This is a 8 way directional walking system for R6, make sure to not leave the id’s empty or it might not work, here is the place file:
Baseplate.rbxl (43.3 KB)
Here is the code:
local char=script.Parent
local cos30=math.cos(math.pi/6)
local cos60=math.cos(math.pi/3)
local animationFolder = game:GetService("ReplicatedStorage"):FindFirstChild("Animations")
if not animationFolder then
error("Animations folder not found")
end
local walkForwardAnim = animationFolder:FindFirstChild("WalkForwardR6")
local walkBackwardAnim = animationFolder:FindFirstChild("WalkBackwardR6")
local walkLeftAnim = animationFolder:FindFirstChild("WalkLeftR6")
local walkRightAnim = animationFolder:FindFirstChild("WalkRightR6")
local walkForwardLeftAnim = animationFolder:FindFirstChild("WalkForwardLeftR6")
local walkForwardRightAnim = animationFolder:FindFirstChild("WalkForwardRightR6")
local walkBackwardLeftAnim = animationFolder:FindFirstChild("WalkBackwardLeftR6")
local walkBackwardRightAnim = animationFolder:FindFirstChild("WalkBackwardRightR6")
if not walkForwardAnim or not walkBackwardAnim or not walkLeftAnim or not walkRightAnim or not walkForwardLeftAnim or not walkForwardRightAnim or not walkBackwardLeftAnim or not walkBackwardRightAnim then
error("One or more walk animations not found")
end
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid.Animator
local animationControllers = {}
local function playAnimation(animation)
local animationController = animationControllers[animation.Name]
if not animationController then
animationController = animator:LoadAnimation(animation)
animationControllers[animation.Name] = animationController
end
if animationController.IsPlaying then
return animationController
end
animationController:Play()
animationController:GetMarkerReachedSignal("End"):Connect(function()
animationController:Stop()
end)
return animationController
end
local function stopAnimation(animationController)
if animationController then
animationController:Stop()
end
end
game["Run Service"].RenderStepped:Connect(function()
local currentAnimationController=nil
local walkDir=char.HumanoidRootPart.CFrame.Rotation:PointToObjectSpace(Vector3.new(char.HumanoidRootPart.Velocity.X,0,char.HumanoidRootPart.Velocity.Z).Unit)
if walkDir.X>cos60 and walkDir.X<cos30 then
if walkDir.Z<0 then
print("forward-right")
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkLeftR6"])
stopAnimation(animationControllers["WalkRightR6"])
currentAnimationController=playAnimation(walkForwardRightAnim)
else
print("backward-right")
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkLeftR6"])
stopAnimation(animationControllers["WalkRightR6"])
currentAnimationController=playAnimation(walkBackwardRightAnim)
end
elseif walkDir.X<-cos60 and walkDir.X>-cos30 then
if walkDir.Z<0 then
print("forward-left")
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkLeftR6"])
stopAnimation(animationControllers["WalkRightR6"])
currentAnimationController=playAnimation(walkForwardLeftAnim)
else
print("backward-left")
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkLeftR6"])
stopAnimation(animationControllers["WalkRightR6"])
currentAnimationController=playAnimation(walkBackwardLeftAnim)
end
elseif walkDir.X>-cos60 and walkDir.X<cos60 then
if walkDir.Z<0 then
print("forward")
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkLeftR6"])
stopAnimation(animationControllers["WalkRightR6"])
currentAnimationController=playAnimation(walkForwardAnim)
else
print("backward")
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkLeftR6"])
stopAnimation(animationControllers["WalkRightR6"])
currentAnimationController=playAnimation(walkBackwardAnim)
end
elseif walkDir.Z>-cos60 and walkDir.Z<cos60 then
if walkDir.X<0 then
print("left")
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkRightR6"])
currentAnimationController=playAnimation(walkLeftAnim)
else
print("right")
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkLeftR6"])
currentAnimationController=playAnimation(walkRightAnim)
end
if currentAnimationController then
currentAnimationController.Priority = Enum.AnimationPriority.Movement
end
else
stopAnimation(animationControllers["WalkForwardR6"])
stopAnimation(animationControllers["WalkForwardLeftR6"])
stopAnimation(animationControllers["WalkForwardRightR6"])
stopAnimation(animationControllers["WalkBackwardR6"])
stopAnimation(animationControllers["WalkBackwardLeftR6"])
stopAnimation(animationControllers["WalkBackwardRightR6"])
stopAnimation(animationControllers["WalkLeftR6"])
stopAnimation(animationControllers["WalkRightR6"])
end
end)
Here is the old version: 4 Way Directional Walking System Open Sourced if anyone wants the 4 way directional walking system.
Credits: David - Roblox
Stay tuned for more resources!