BLOXBUILDS
Discord
Back
COMBAT

Dash / Dodge

Paste into StarterPlayerScripts as a LocalScript. Press Q to dash in the move direction. The dash cannot be used again until the cooldown ends.

-- Paste into StarterPlayer > StarterPlayerScripts as a LocalScript.

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")

local DASH_SPEED = 80
local COOLDOWN = 1

local player = Players.LocalPlayer
local lastDash = 0

UserInputService.InputBegan:Connect(function(input, processed)
	if processed or input.KeyCode ~= Enum.KeyCode.Q then
		return
	end
	if os.clock() - lastDash < COOLDOWN then
		return
	end

	local character = player.Character
	local root = character and character:FindFirstChild("HumanoidRootPart")
	local humanoid = character and character:FindFirstChildOfClass("Humanoid")
	if not root or not root:IsA("BasePart") or not humanoid then
		return
	end

	lastDash = os.clock()
	local direction = if humanoid.MoveDirection.Magnitude > 0 then humanoid.MoveDirection else root.CFrame.LookVector
	root.AssemblyLinearVelocity = direction.Unit * DASH_SPEED + Vector3.new(0, root.AssemblyLinearVelocity.Y, 0)
end)