Play dash animation according to the direction player dashed in

What do you want to achieve?
I’ve been trying to make a dashing system that plays an animation when dashes in a certain directional e.g. if player dashes forwards, the forwards animation player etc.

What is the issue?
I’m not really sure how to go about it, I’ve tried using a table to make the animation play but no luck.

What solutions have you tried so far?
This is the current script it only allow the player dash forwards.

local Keybind = Enum.KeyCode.Q

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local UIS = game:GetService("UserInputService")

local DashTime = .2
local Force = 70

local Anims = {
	["Left"] = Humanoid:LoadAnimation(script.Animations:WaitForChild("Left")),
	["Right"] = Humanoid:LoadAnimation(script.Animations:WaitForChild("Right")),
	["Foward"] = Humanoid:LoadAnimation(script.Animations:WaitForChild("Forward")),
	["Back"] = Humanoid:LoadAnimation(script.Animations:WaitForChild("Back"))
}

UIS.InputBegan:Connect(function(Key)
	if Key.KeyCode == Keybind then
		local Slide = Instance.new("BodyVelocity")
		Slide.MaxForce = Vector3.new(1,1,1) * 20000
		Slide.Velocity = Humanoid.MoveDirection * Force
		Slide.Parent = Character.HumanoidRootPart

		wait(DashTime)

		game.Debris:AddItem(Slide, 0.1)	
	end
end)

Any help is greatly appreciated

You could use IsKeyDown to check which key is pressed, then play the animation according to the key.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.