How to make the player dash in their moving direction

Im trying to replicate the dash from a game called “YBA”
https://www.roblox.com/games/2809202155/Your-Bizarre-Adventure#!/game-instances

in the game you can dash in your moving direction and every direction has its own animation

this is my current script:

local Keybind = Enum.KeyCode.LeftAlt
local Blocking = false

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

local InputSerive = game:GetService("UserInputService")

local DashTime = .2
local Force = 70

local Anims = {
	["Left"] = Animator:LoadAnimation(script:WaitForChild("Left")),
	["Right"] = Animator:LoadAnimation(script:WaitForChild("Right")),
	["Foward"] = Animator:LoadAnimation(script:WaitForChild("Foward")),
	["Back"] = Animator:LoadAnimation(script:WaitForChild("Back"))
}

InputSerive.InputBegan:Connect(function(Key)
	if Key.KeyCode == Keybind then

		local Slide = Instance.new("BodyVelocity")
		Slide.MaxForce = Vector3.new(1,0,1) * 30000
		Slide.Velocity = Humanoid.MoveDirection * Force
		Slide.Parent = Character.HumanoidRootPart
		
		wait(DashTime)

		game.Debris:AddItem(Slide, 0.1)		
		for count = 1, 2 do
			wait(0.05)
			Slide.Velocity *= 0.3
		end
		
	end
end)

i figured how to make the dash but can’t figure out how to get the animations

local UIS = game:GetService("UserInputService")
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Dashes = {
	[Enum.KeyCode.W] = {Humanoid:LoadAnimation(script:WaitForChild("Forward")), function() return Character.HumanoidRootPart.CFrame.LookVector end},
	[Enum.KeyCode.A] = {Humanoid:LoadAnimation(script:WaitForChild("Left")), function() return -Character.HumanoidRootPart.CFrame.RightVector end},
	[Enum.KeyCode.S] = {Humanoid:LoadAnimation(script:WaitForChild("Back")), function() return -Character.HumanoidRootPart.CFrame.LookVector end},
	[Enum.KeyCode.D] = {Humanoid:LoadAnimation(script:WaitForChild("Right")), function() return Character.HumanoidRootPart.CFrame.RightVector end}
}


local DashTime = .2
local Force = 70
local DoubleTapSens = 0.2


local LastKeyCode = nil
local LastTick = nil
UIS.InputBegan:Connect(function(Key)
	if LastKeyCode == nil then LastKeyCode = Key.KeyCode LastTick = tick() return end
	if LastKeyCode == Key.KeyCode and tick() - LastTick <= DoubleTapSens then
		local Dash = Dashes[Key.KeyCode]
		if not Dash then LastTick = tick() return end
		Dash[1]:Play()
		local Slide = Instance.new("BodyVelocity")
		Slide.MaxForce = Vector3.new(1,1,1) * 30000
		Slide.Velocity = Dash[2]()*Force
		Slide.Parent = Character.HumanoidRootPart
		wait(DashTime)
		game.Debris:AddItem(Slide, 0.1)		
		for count = 1, 2 do
			wait(0.05)
			Slide.Velocity *= .3
		end
	else
		LastKeyCode = Key.KeyCode
	end
	LastTick = tick()
end)
1 Like