How to make a W A S D dash system?
I want to make a WASD Dash System however all the things I tried didn't work. I already have created animations for ASD and I want no animations for W. All I want is a simple teleport into your direction and set the animation based on it. It would also be great if it would have I-Frames.
I saved the animations into a folder called "Dash" in ReplicatedStorage. The names are DashL, DashR and DashB, for Left, Right and Back respectively.
I also want to implement some anime teleport particles (like this: https://tenor.com/view/teleportation-goku-dragon-ball-z-super-saiyan-dbz-gif-17300403) . They are going to be just simple particles eminating from the player. Nothing special.
Here is the code I tried using. Instead of teleporting, it just gives a speed boost.
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | local Players = game:GetService( "Players" ) |
03 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
05 | local Character = script.Parent |
06 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
08 | local DashL = Humanoid:LoadAnimation(ReplicatedStorage.Dash.DashL) |
09 | local DashR = Humanoid:LoadAnimation(ReplicatedStorage.Dash.DashR) |
10 | local DashB = Humanoid:LoadAnimation(ReplicatedStorage.Dash.DashB) |
15 | Keybind = Enum.KeyCode.Q, |
20 | UserInputService.InputBegan:Connect( function (Input, GameProcessedEvent) |
21 | if Input.KeyCode = = Properties.Keybind then |
23 | if tick() - Properties.LastDash > = Properties.Cooldown then |
24 | Properties.LastDash = tick() |
26 | if Input.KeyCode = = Input.KeyCode.A then |
27 | DashL:Play() elseif Input.KeyCode = = Input.KeyCode.D then |
28 | DashR:Play() elseif Input.KeyCode = = Input.KeyCode.B then |
33 | local BodyVelocity = Instance.new( "BodyVelocity" ) |
34 | BodyVelocity.MaxForce = Vector 3. new( 1 , 1 , 1 ) * 500000 |
35 | BodyVelocity.Velocity = Character.HumanoidRootPart.CFrame.LookVector * Properties.Velocity |
36 | BodyVelocity.Parent = Character.HumanoidRootPart |
38 | wait(Properties.Duration) |
39 | BodyVelocity:Destroy() |