How do i make a dash?

Basically what i want to do is when the player presses Q, they dash a bit forward, based on where the character is looking.

That’s basically it, if anyone is able to help i would appreciate a lot.

7 Likes

For a very basic dash, you could insert a BodyVelocity into the HumanoidRootPart of the character every time Q is pressed, then set the velocity of it to be the lookVector of the HumanoidRootPart * number.

1 Like
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local debounce = false

uis.InputBegan:Connect(function(key, processed)
	if debounce or processed then
		return
	end

	if key.KeyCode == Enum.KeyCode.Q then
		debounce = true
		humanoid.WalkSpeed += 8
		task.wait(0.5)
		humanoid.WalkSpeed -= 8
	end

	task.wait(1.5)
	debounce = false
end)

Local script in StarterCharacterScripts folder. Values can be changed to fit your needs.

5 Likes

If you want a dash that they can change directions with you could increase the walkspeed to something high for a split second and then set it back to normal.

1 Like

Was gonna say this, you should also add the bodyvelocity to debris so you don’t have to pause the script and the dash is basically in an instant.

…like so:

	local Bv = Instance.new("BodyVelocity", script.Parent.Torso)
	Bv.P = 1250 -- doesn't really matter
	Bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge) -- doesn't really matter
	Bv.Velocity = script.Parent.Torso.CFrame.lookVector*50 -- adjust this until its right
-- putting it to negative will make the player go back if you want that too
	game.Debris:AddItem(Bv,0.1) -- adjust 0.1 until its right too
6 Likes

Nah scratch that I’ll make an entire script for you 'cause I’m bored

Dashing Ability! - Roblox (uncopylocked)

How it looks: (everything is configurable!)


You might see me slide into the floor a bit, this is because of how R15 animations work, if you want you can base it off the head and it’ll be a bit better

Code (use the uncopylocked place’s version, otherwise this will error out btw):

local Debris = game:GetService('Debris')
local UIS = game:GetService('UserInputService')
local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character

-- Settings
local DashTime = 0.2
local Amount = 50

local MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local P = 1250

local Cooldown = false
local CooldownTime = 2

local TrailEnabled = true
local R15 = true

UIS.InputBegan:Connect(function(i, g)
	if not g and i.KeyCode == Enum.KeyCode.Q and Cooldown == false then
		local Bv = Instance.new("BodyVelocity")
		if R15 then
			Bv.Parent = Character.UpperTorso
		else
			Bv.Parent = Character.Torso
		end
		Bv.P = P
		script.Dash:Play()
		Bv.MaxForce = MaxForce
		if R15 then
			Bv.Velocity = Character.UpperTorso.CFrame.lookVector*Amount
		else
			Bv.Velocity = Character.Torso.CFrame.lookVector*Amount
		end
		Debris:AddItem(Bv,DashTime)
		Cooldown = true
		for _, v in pairs(Character:GetChildren()) do
			if v:IsA("BasePart") and TrailEnabled then
				local Att1 = Instance.new("Attachment", v)
				Att1.Orientation = Vector3.new(-90, 0, 0)
				Att1.Position = Vector3.new(0,0.5,0)
				local Att2 = Instance.new("Attachment", v)
				Att2.Orientation = Vector3.new(-90, 0, 0)
				Att2.Position = Vector3.new(0,-0.5,0)
				local Trail = Instance.new("Trail", v)
				Trail.Attachment0 = Att1
				Trail.Attachment1 = Att2
				Trail.Lifetime = 0.1
				Debris:AddItem(Att1, CooldownTime)
				Debris:AddItem(Att2, CooldownTime)
				Debris:AddItem(Trail, 0.5)
			end
		end
		task.wait(CooldownTime)
		Cooldown = false
	end
end)
27 Likes

To make this 10x better and have it work with other animations just use the Humanoids Move direction instead of the Torsos lookVector!

Bv.Velocity = Character.Humanoid.MoveDirection*Amount
9 Likes

Yeah, I figured this out shortly after I posted that and forgot to update it :slight_smile:

1 Like

Bv.Velocity = Character.HumanoidRootPart.CFrame.lookVector*Amount

I would recommend this! The character won’t be pushed into the floor + the character will also dash forward, if not currently moving

1 Like

@Faczki

Using math.huge for the MaxForce of a BodyVelocity in the case of dashes can make the dashes too aggressive and, once you dash onto a part, you could get easily flung.

What I recommend is:

  1. In case you want your dash to “fly” (not get affected by gravity): Vector3.new(100000, 100000, 100000).
  2. In case you don’t want to “fly”: Vector3.new(100000, 0, 100000).

An aditional information:
Even changing the MaxForce to something lower can make you get flung or “ragdolled” while dashing. I recommend disabling the FallingDown HumanoidStateType if you often fall while dashing onto a part in a LocalScript.

5 Likes

Woah thanks alot for those recommendations!

1 Like